Skip to content

Commit 1133ef2

Browse files
committed
ggml : remove deprecated custom ops
ggml-ci
1 parent 918ff70 commit 1133ef2

File tree

5 files changed

+2
-482
lines changed

5 files changed

+2
-482
lines changed

Diff for: include/ggml.h

-84
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,6 @@ extern "C" {
507507

508508
GGML_OP_UNARY,
509509

510-
GGML_OP_MAP_UNARY,
511-
GGML_OP_MAP_BINARY,
512-
513-
GGML_OP_MAP_CUSTOM1_F32,
514-
GGML_OP_MAP_CUSTOM2_F32,
515-
GGML_OP_MAP_CUSTOM3_F32,
516-
517510
GGML_OP_MAP_CUSTOM1,
518511
GGML_OP_MAP_CUSTOM2,
519512
GGML_OP_MAP_CUSTOM3,
@@ -1918,83 +1911,6 @@ extern "C" {
19181911

19191912
// custom operators
19201913

1921-
typedef void (*ggml_unary_op_f32_t) (const int, float *, const float *);
1922-
typedef void (*ggml_binary_op_f32_t)(const int, float *, const float *, const float *);
1923-
1924-
typedef void (*ggml_custom1_op_f32_t)(struct ggml_tensor *, const struct ggml_tensor *);
1925-
typedef void (*ggml_custom2_op_f32_t)(struct ggml_tensor *, const struct ggml_tensor *, const struct ggml_tensor *);
1926-
typedef void (*ggml_custom3_op_f32_t)(struct ggml_tensor *, const struct ggml_tensor *, const struct ggml_tensor *, const struct ggml_tensor *);
1927-
1928-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_unary_f32(
1929-
struct ggml_context * ctx,
1930-
struct ggml_tensor * a,
1931-
ggml_unary_op_f32_t fun),
1932-
"use ggml_map_custom1 instead");
1933-
1934-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_unary_inplace_f32(
1935-
struct ggml_context * ctx,
1936-
struct ggml_tensor * a,
1937-
ggml_unary_op_f32_t fun),
1938-
"use ggml_map_custom1_inplace instead");
1939-
1940-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_binary_f32(
1941-
struct ggml_context * ctx,
1942-
struct ggml_tensor * a,
1943-
struct ggml_tensor * b,
1944-
ggml_binary_op_f32_t fun),
1945-
"use ggml_map_custom2 instead");
1946-
1947-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_binary_inplace_f32(
1948-
struct ggml_context * ctx,
1949-
struct ggml_tensor * a,
1950-
struct ggml_tensor * b,
1951-
ggml_binary_op_f32_t fun),
1952-
"use ggml_map_custom2_inplace instead");
1953-
1954-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_custom1_f32(
1955-
struct ggml_context * ctx,
1956-
struct ggml_tensor * a,
1957-
ggml_custom1_op_f32_t fun),
1958-
"use ggml_map_custom1 instead");
1959-
1960-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_custom1_inplace_f32(
1961-
struct ggml_context * ctx,
1962-
struct ggml_tensor * a,
1963-
ggml_custom1_op_f32_t fun),
1964-
"use ggml_map_custom1_inplace instead");
1965-
1966-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_custom2_f32(
1967-
struct ggml_context * ctx,
1968-
struct ggml_tensor * a,
1969-
struct ggml_tensor * b,
1970-
ggml_custom2_op_f32_t fun),
1971-
"use ggml_map_custom2 instead");
1972-
1973-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_custom2_inplace_f32(
1974-
struct ggml_context * ctx,
1975-
struct ggml_tensor * a,
1976-
struct ggml_tensor * b,
1977-
ggml_custom2_op_f32_t fun),
1978-
"use ggml_map_custom2_inplace instead");
1979-
1980-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_custom3_f32(
1981-
struct ggml_context * ctx,
1982-
struct ggml_tensor * a,
1983-
struct ggml_tensor * b,
1984-
struct ggml_tensor * c,
1985-
ggml_custom3_op_f32_t fun),
1986-
"use ggml_map_custom3 instead");
1987-
1988-
GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_map_custom3_inplace_f32(
1989-
struct ggml_context * ctx,
1990-
struct ggml_tensor * a,
1991-
struct ggml_tensor * b,
1992-
struct ggml_tensor * c,
1993-
ggml_custom3_op_f32_t fun),
1994-
"use ggml_map_custom3_inplace instead");
1995-
1996-
// custom operators v2
1997-
19981914
typedef void (*ggml_custom1_op_t)(struct ggml_tensor * dst , const struct ggml_tensor * a, int ith, int nth, void * userdata);
19991915
typedef void (*ggml_custom2_op_t)(struct ggml_tensor * dst , const struct ggml_tensor * a, const struct ggml_tensor * b, int ith, int nth, void * userdata);
20001916
typedef void (*ggml_custom3_op_t)(struct ggml_tensor * dst , const struct ggml_tensor * a, const struct ggml_tensor * b, const struct ggml_tensor * c, int ith, int nth, void * userdata);

Diff for: src/ggml-cpu/ggml-cpu.c

-43
Original file line numberDiff line numberDiff line change
@@ -2027,41 +2027,6 @@ static void ggml_compute_forward(struct ggml_compute_params * params, struct ggm
20272027
{
20282028
ggml_compute_forward_rwkv_wkv7(params, tensor);
20292029
} break;
2030-
case GGML_OP_MAP_UNARY:
2031-
{
2032-
ggml_unary_op_f32_t fun;
2033-
memcpy(&fun, tensor->op_params, sizeof(fun));
2034-
ggml_compute_forward_map_unary(params, tensor, fun);
2035-
}
2036-
break;
2037-
case GGML_OP_MAP_BINARY:
2038-
{
2039-
ggml_binary_op_f32_t fun;
2040-
memcpy(&fun, tensor->op_params, sizeof(fun));
2041-
ggml_compute_forward_map_binary(params, tensor, fun);
2042-
}
2043-
break;
2044-
case GGML_OP_MAP_CUSTOM1_F32:
2045-
{
2046-
ggml_custom1_op_f32_t fun;
2047-
memcpy(&fun, tensor->op_params, sizeof(fun));
2048-
ggml_compute_forward_map_custom1_f32(params, tensor, fun);
2049-
}
2050-
break;
2051-
case GGML_OP_MAP_CUSTOM2_F32:
2052-
{
2053-
ggml_custom2_op_f32_t fun;
2054-
memcpy(&fun, tensor->op_params, sizeof(fun));
2055-
ggml_compute_forward_map_custom2_f32(params, tensor, fun);
2056-
}
2057-
break;
2058-
case GGML_OP_MAP_CUSTOM3_F32:
2059-
{
2060-
ggml_custom3_op_f32_t fun;
2061-
memcpy(&fun, tensor->op_params, sizeof(fun));
2062-
ggml_compute_forward_map_custom3_f32(params, tensor, fun);
2063-
}
2064-
break;
20652030
case GGML_OP_MAP_CUSTOM1:
20662031
{
20672032
ggml_compute_forward_map_custom1(params, tensor);
@@ -2333,14 +2298,6 @@ static int ggml_get_n_tasks(struct ggml_tensor * node, int n_threads) {
23332298
case GGML_OP_WIN_PART:
23342299
case GGML_OP_WIN_UNPART:
23352300
case GGML_OP_GET_REL_POS:
2336-
case GGML_OP_MAP_UNARY:
2337-
case GGML_OP_MAP_BINARY:
2338-
case GGML_OP_MAP_CUSTOM1_F32:
2339-
case GGML_OP_MAP_CUSTOM2_F32:
2340-
case GGML_OP_MAP_CUSTOM3_F32:
2341-
{
2342-
n_tasks = 1;
2343-
} break;
23442301
case GGML_OP_MAP_CUSTOM1:
23452302
{
23462303
struct ggml_map_custom1_op_params p;

Diff for: src/ggml-cpu/ops.cpp

-146
Original file line numberDiff line numberDiff line change
@@ -8264,152 +8264,6 @@ void ggml_compute_forward_rwkv_wkv7(
82648264
}
82658265
}
82668266

8267-
// ggml_compute_forward_map_unary
8268-
8269-
static void ggml_compute_forward_map_unary_f32(
8270-
const ggml_compute_params * params,
8271-
ggml_tensor * dst,
8272-
const ggml_unary_op_f32_t fun) {
8273-
8274-
const ggml_tensor * src0 = dst->src[0];
8275-
8276-
if (params->ith != 0) {
8277-
return;
8278-
}
8279-
8280-
assert(ggml_is_contiguous_1(src0));
8281-
assert(ggml_is_contiguous_1(dst));
8282-
assert(ggml_are_same_shape(src0, dst));
8283-
8284-
const int n = ggml_nrows(src0);
8285-
const int nc = src0->ne[0];
8286-
8287-
for (int i = 0; i < n; i++) {
8288-
fun(nc,
8289-
(float *) ((char *) dst->data + i*( dst->nb[1])),
8290-
(float *) ((char *) src0->data + i*(src0->nb[1])));
8291-
}
8292-
}
8293-
8294-
void ggml_compute_forward_map_unary(
8295-
const ggml_compute_params * params,
8296-
ggml_tensor * dst,
8297-
const ggml_unary_op_f32_t fun) {
8298-
8299-
const ggml_tensor * src0 = dst->src[0];
8300-
8301-
switch (src0->type) {
8302-
case GGML_TYPE_F32:
8303-
{
8304-
ggml_compute_forward_map_unary_f32(params, dst, fun);
8305-
} break;
8306-
default:
8307-
{
8308-
GGML_ABORT("fatal error");
8309-
}
8310-
}
8311-
}
8312-
8313-
// ggml_compute_forward_map_binary
8314-
8315-
static void ggml_compute_forward_map_binary_f32(
8316-
const ggml_compute_params * params,
8317-
ggml_tensor * dst,
8318-
const ggml_binary_op_f32_t fun) {
8319-
8320-
const ggml_tensor * src0 = dst->src[0];
8321-
const ggml_tensor * src1 = dst->src[1];
8322-
8323-
if (params->ith != 0) {
8324-
return;
8325-
}
8326-
8327-
assert(ggml_is_contiguous_1(src0));
8328-
assert(ggml_is_contiguous_1(src1));
8329-
assert(ggml_is_contiguous_1(dst));
8330-
assert(ggml_are_same_shape(src0, src1) && ggml_are_same_shape(src0, dst));
8331-
8332-
const int n = ggml_nrows(src0);
8333-
const int nc = src0->ne[0];
8334-
8335-
for (int i = 0; i < n; i++) {
8336-
fun(nc,
8337-
(float *) ((char *) dst->data + i*( dst->nb[1])),
8338-
(float *) ((char *) src0->data + i*(src0->nb[1])),
8339-
(float *) ((char *) src1->data + i*(src1->nb[1])));
8340-
}
8341-
}
8342-
8343-
void ggml_compute_forward_map_binary(
8344-
const ggml_compute_params * params,
8345-
ggml_tensor * dst,
8346-
const ggml_binary_op_f32_t fun) {
8347-
8348-
const ggml_tensor * src0 = dst->src[0];
8349-
8350-
switch (src0->type) {
8351-
case GGML_TYPE_F32:
8352-
{
8353-
ggml_compute_forward_map_binary_f32(params, dst, fun);
8354-
} break;
8355-
default:
8356-
{
8357-
GGML_ABORT("fatal error");
8358-
}
8359-
}
8360-
}
8361-
8362-
// ggml_compute_forward_map_custom1
8363-
8364-
void ggml_compute_forward_map_custom1_f32(
8365-
const ggml_compute_params * params,
8366-
ggml_tensor * dst,
8367-
const ggml_custom1_op_f32_t fun) {
8368-
8369-
const ggml_tensor * a = dst->src[0];
8370-
8371-
if (params->ith != 0) {
8372-
return;
8373-
}
8374-
8375-
fun(dst, a);
8376-
}
8377-
8378-
// ggml_compute_forward_map_custom2
8379-
8380-
void ggml_compute_forward_map_custom2_f32(
8381-
const ggml_compute_params * params,
8382-
ggml_tensor * dst,
8383-
const ggml_custom2_op_f32_t fun) {
8384-
8385-
const ggml_tensor * a = dst->src[0];
8386-
const ggml_tensor * b = dst->src[1];
8387-
8388-
if (params->ith != 0) {
8389-
return;
8390-
}
8391-
8392-
fun(dst, a, b);
8393-
}
8394-
8395-
// ggml_compute_forward_map_custom3
8396-
8397-
void ggml_compute_forward_map_custom3_f32(
8398-
const ggml_compute_params * params,
8399-
ggml_tensor * dst,
8400-
const ggml_custom3_op_f32_t fun) {
8401-
8402-
const ggml_tensor * a = dst->src[0];
8403-
const ggml_tensor * b = dst->src[1];
8404-
const ggml_tensor * c = dst->src[1];
8405-
8406-
if (params->ith != 0) {
8407-
return;
8408-
}
8409-
8410-
fun(dst, a, b, c);
8411-
}
8412-
84138267
// ggml_compute_forward_map_custom1
84148268

84158269
void ggml_compute_forward_map_custom1(

Diff for: src/ggml-cpu/ops.h

-20
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,6 @@ void ggml_compute_forward_add_rel_pos(const struct ggml_compute_params * params,
9696
void ggml_compute_forward_rwkv_wkv6(const struct ggml_compute_params * params, struct ggml_tensor * dst);
9797
void ggml_compute_forward_rwkv_wkv7(const struct ggml_compute_params * params, struct ggml_tensor * dst);
9898
void ggml_compute_forward_gla(const struct ggml_compute_params * params, struct ggml_tensor * dst);
99-
void ggml_compute_forward_map_unary(
100-
const struct ggml_compute_params * params,
101-
struct ggml_tensor * dst,
102-
const ggml_unary_op_f32_t fun);
103-
void ggml_compute_forward_map_binary(
104-
const struct ggml_compute_params * params,
105-
struct ggml_tensor * dst,
106-
const ggml_binary_op_f32_t fun);
107-
void ggml_compute_forward_map_custom1_f32(
108-
const struct ggml_compute_params * params,
109-
struct ggml_tensor * dst,
110-
const ggml_custom1_op_f32_t fun);
111-
void ggml_compute_forward_map_custom2_f32(
112-
const struct ggml_compute_params * params,
113-
struct ggml_tensor * dst,
114-
const ggml_custom2_op_f32_t fun);
115-
void ggml_compute_forward_map_custom3_f32(
116-
const struct ggml_compute_params * params,
117-
struct ggml_tensor * dst,
118-
const ggml_custom3_op_f32_t fun);
11999
void ggml_compute_forward_map_custom1(const struct ggml_compute_params * params, struct ggml_tensor * dst);
120100
void ggml_compute_forward_map_custom2(const struct ggml_compute_params * params, struct ggml_tensor * dst);
121101
void ggml_compute_forward_map_custom3(const struct ggml_compute_params * params, struct ggml_tensor * dst);

0 commit comments

Comments
 (0)