aboutsummaryrefslogtreecommitdiff
path: root/ggml.h
diff options
context:
space:
mode:
authorKerfuffle <44031344+KerfuffleV2@users.noreply.github.com>2023-04-14 08:43:55 -0600
committerGitHub <noreply@github.com>2023-04-14 17:43:55 +0300
commitc9a59b70a54e0bc05777df287feaea3dbe0310c4 (patch)
tree3be046a57809261cc26f69b5ddd9d58b1f65ba2b /ggml.h
parenta32f7acc9f54dba1c728cb1e596bd00bf3b4eb5f (diff)
ggml : add unary and binary map operations (#874)
* GGML map ops proof of concept. * Various cleanups. Add handling for task setting. Add handling for ggml_compute_backward. Rename functions to ggml_map_unary_f32 and ggml_map_binary_f32 Fix compiler warnings related to casting function pointers and `void *` Reorder functions and definitions based on the GGML op number. Use typedefs for map op function pointer types. * Fix position of map ops cases in ggml_compute_forward
Diffstat (limited to 'ggml.h')
-rw-r--r--ggml.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/ggml.h b/ggml.h
index c06c09e..bdff0b4 100644
--- a/ggml.h
+++ b/ggml.h
@@ -253,6 +253,9 @@ enum ggml_op {
GGML_OP_FLASH_ATTN,
GGML_OP_FLASH_FF,
+ GGML_OP_MAP_UNARY,
+ GGML_OP_MAP_BINARY,
+
GGML_OP_COUNT,
};
@@ -652,6 +655,21 @@ struct ggml_tensor * ggml_flash_ff(
struct ggml_tensor * c0,
struct ggml_tensor * c1);
+// Mapping operations
+typedef void (*ggml_unary_op_f32_t)(const int, float *, const float *);
+typedef void (*ggml_binary_op_f32_t)(const int, float *, const float *, const float *);
+
+struct ggml_tensor * ggml_map_unary_f32(
+ struct ggml_context * ctx,
+ struct ggml_tensor * a,
+ const ggml_unary_op_f32_t fun);
+
+struct ggml_tensor * ggml_map_binary_f32(
+ struct ggml_context * ctx,
+ struct ggml_tensor * a,
+ struct ggml_tensor * b,
+ const ggml_binary_op_f32_t fun);
+
//
// automatic differentiation
//