@@ -507,17 +507,12 @@ 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 ,
520513
514+ GGML_OP_CUSTOM ,
515+
521516 GGML_OP_CROSS_ENTROPY_LOSS ,
522517 GGML_OP_CROSS_ENTROPY_LOSS_BACK ,
523518 GGML_OP_OPT_STEP_ADAMW ,
@@ -1722,24 +1717,29 @@ extern "C" {
17221717 float p0 ,
17231718 float p1 );
17241719
1725- // nearest interpolate
1720+ enum ggml_scale_mode {
1721+ GGML_SCALE_MODE_NEAREST = 0 ,
1722+ GGML_SCALE_MODE_BILINEAR = 1 ,
1723+ };
1724+
1725+ // interpolate
17261726 // multiplies ne0 and ne1 by scale factor
1727- // used in stable-diffusion
17281727 GGML_API struct ggml_tensor * ggml_upscale (
17291728 struct ggml_context * ctx ,
17301729 struct ggml_tensor * a ,
1731- int scale_factor );
1730+ int scale_factor ,
1731+ enum ggml_scale_mode mode );
17321732
1733- // nearest interpolate
1734- // nearest interpolate to specified dimensions
1735- // used in tortoise.cpp
1733+ // interpolate
1734+ // interpolate scale to specified dimensions
17361735 GGML_API struct ggml_tensor * ggml_upscale_ext (
17371736 struct ggml_context * ctx ,
17381737 struct ggml_tensor * a ,
17391738 int ne0 ,
17401739 int ne1 ,
17411740 int ne2 ,
1742- int ne3 );
1741+ int ne3 ,
1742+ enum ggml_scale_mode mode );
17431743
17441744 // pad each dimension with zeros: [x, ..., x] -> [x, ..., x, 0, ..., 0]
17451745 GGML_API struct ggml_tensor * ggml_pad (
@@ -1791,11 +1791,11 @@ extern "C" {
17911791
17921792#define GGML_KQ_MASK_PAD 64
17931793
1794- // q: [n_embd , n_batch, n_head, 1]
1795- // k: [n_embd , n_kv, n_head_kv, 1]
1796- // v: [n_embd , n_kv, n_head_kv, 1] !! not transposed !!
1797- // mask: [n_kv, n_batch_pad, 1, 1] !! n_batch_pad = GGML_PAD(n_batch, GGML_KQ_MASK_PAD) !!
1798- // res: [n_embd , n_head, n_batch, 1] !! permuted !!
1794+ // q: [n_embd_k , n_batch, n_head, 1]
1795+ // k: [n_embd_k , n_kv, n_head_kv, 1]
1796+ // v: [n_embd_v , n_kv, n_head_kv, 1] !! not transposed !!
1797+ // mask: [n_kv, n_batch_pad, 1, 1] !! n_batch_pad = GGML_PAD(n_batch, GGML_KQ_MASK_PAD) !!
1798+ // res: [n_embd_v , n_head, n_batch, 1] !! permuted !!
17991799 GGML_API struct ggml_tensor * ggml_flash_attn_ext (
18001800 struct ggml_context * ctx ,
18011801 struct ggml_tensor * q ,
@@ -1916,83 +1916,6 @@ extern "C" {
19161916
19171917 // custom operators
19181918
1919- typedef void (* ggml_unary_op_f32_t ) (const int , float * , const float * );
1920- typedef void (* ggml_binary_op_f32_t )(const int , float * , const float * , const float * );
1921-
1922- typedef void (* ggml_custom1_op_f32_t )(struct ggml_tensor * , const struct ggml_tensor * );
1923- typedef void (* ggml_custom2_op_f32_t )(struct ggml_tensor * , const struct ggml_tensor * , const struct ggml_tensor * );
1924- typedef void (* ggml_custom3_op_f32_t )(struct ggml_tensor * , const struct ggml_tensor * , const struct ggml_tensor * , const struct ggml_tensor * );
1925-
1926- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_unary_f32 (
1927- struct ggml_context * ctx ,
1928- struct ggml_tensor * a ,
1929- ggml_unary_op_f32_t fun ),
1930- "use ggml_map_custom1 instead" );
1931-
1932- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_unary_inplace_f32 (
1933- struct ggml_context * ctx ,
1934- struct ggml_tensor * a ,
1935- ggml_unary_op_f32_t fun ),
1936- "use ggml_map_custom1_inplace instead" );
1937-
1938- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_binary_f32 (
1939- struct ggml_context * ctx ,
1940- struct ggml_tensor * a ,
1941- struct ggml_tensor * b ,
1942- ggml_binary_op_f32_t fun ),
1943- "use ggml_map_custom2 instead" );
1944-
1945- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_binary_inplace_f32 (
1946- struct ggml_context * ctx ,
1947- struct ggml_tensor * a ,
1948- struct ggml_tensor * b ,
1949- ggml_binary_op_f32_t fun ),
1950- "use ggml_map_custom2_inplace instead" );
1951-
1952- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_custom1_f32 (
1953- struct ggml_context * ctx ,
1954- struct ggml_tensor * a ,
1955- ggml_custom1_op_f32_t fun ),
1956- "use ggml_map_custom1 instead" );
1957-
1958- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_custom1_inplace_f32 (
1959- struct ggml_context * ctx ,
1960- struct ggml_tensor * a ,
1961- ggml_custom1_op_f32_t fun ),
1962- "use ggml_map_custom1_inplace instead" );
1963-
1964- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_custom2_f32 (
1965- struct ggml_context * ctx ,
1966- struct ggml_tensor * a ,
1967- struct ggml_tensor * b ,
1968- ggml_custom2_op_f32_t fun ),
1969- "use ggml_map_custom2 instead" );
1970-
1971- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_custom2_inplace_f32 (
1972- struct ggml_context * ctx ,
1973- struct ggml_tensor * a ,
1974- struct ggml_tensor * b ,
1975- ggml_custom2_op_f32_t fun ),
1976- "use ggml_map_custom2_inplace instead" );
1977-
1978- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_custom3_f32 (
1979- struct ggml_context * ctx ,
1980- struct ggml_tensor * a ,
1981- struct ggml_tensor * b ,
1982- struct ggml_tensor * c ,
1983- ggml_custom3_op_f32_t fun ),
1984- "use ggml_map_custom3 instead" );
1985-
1986- GGML_DEPRECATED (GGML_API struct ggml_tensor * ggml_map_custom3_inplace_f32 (
1987- struct ggml_context * ctx ,
1988- struct ggml_tensor * a ,
1989- struct ggml_tensor * b ,
1990- struct ggml_tensor * c ,
1991- ggml_custom3_op_f32_t fun ),
1992- "use ggml_map_custom3_inplace instead" );
1993-
1994- // custom operators v2
1995-
19961919 typedef void (* ggml_custom1_op_t )(struct ggml_tensor * dst , const struct ggml_tensor * a , int ith , int nth , void * userdata );
19971920 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 );
19981921 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 );
@@ -2048,6 +1971,30 @@ extern "C" {
20481971 int n_tasks ,
20491972 void * userdata );
20501973
1974+ typedef void (* ggml_custom_op_t )(struct ggml_tensor * dst , int ith , int nth , void * userdata );
1975+
1976+ GGML_API struct ggml_tensor * ggml_custom_4d (
1977+ struct ggml_context * ctx ,
1978+ enum ggml_type type ,
1979+ int64_t ne0 ,
1980+ int64_t ne1 ,
1981+ int64_t ne2 ,
1982+ int64_t ne3 ,
1983+ struct ggml_tensor * * args ,
1984+ int n_args ,
1985+ ggml_custom_op_t fun ,
1986+ int n_tasks ,
1987+ void * userdata );
1988+
1989+ GGML_API struct ggml_tensor * ggml_custom_inplace (
1990+ struct ggml_context * ctx ,
1991+ struct ggml_tensor * a ,
1992+ struct ggml_tensor * * args ,
1993+ int n_args ,
1994+ ggml_custom_op_t fun ,
1995+ int n_tasks ,
1996+ void * userdata );
1997+
20511998 // loss function
20521999
20532000 GGML_API struct ggml_tensor * ggml_cross_entropy_loss (
0 commit comments