diff --git a/ggml/include/ggml.h b/ggml/include/ggml.h index 1dd98cfe76..f3a2726080 100644 --- a/ggml/include/ggml.h +++ b/ggml/include/ggml.h @@ -2683,6 +2683,10 @@ extern "C" { // Other backends: number of workgroups and threads of a workgroup, in each dimension GGML_API void ggml_custom_sched_set_n_groups (struct ggml_custom_sched * sched, int n0, int n1, int n2); GGML_API void ggml_custom_sched_set_group_size(struct ggml_custom_sched * sched, int n0, int n1, int n2); + // A hint: the node can run next to the nodes after it, until the first node that takes it as an argument + // The nodes in between must not need what the kernel writes. A backend can ignore it + // With ggml_backend_sched the node and its arguments stay allocated until then + GGML_API void ggml_custom_sched_set_async(struct ggml_custom_sched * sched, bool async); // A node of the op: the kernels of the op are set before, the op must outlive the graph, params is copied GGML_API struct ggml_tensor * ggml_custom_op_4d( diff --git a/ggml/src/ggml-impl.h b/ggml/src/ggml-impl.h index c5e9ee5558..5cb680ab72 100644 --- a/ggml/src/ggml-impl.h +++ b/ggml/src/ggml-impl.h @@ -223,6 +223,7 @@ struct ggml_custom_sched { int n_tasks; // CPU int n_groups[3]; // other backends int group_size[3]; + bool async; // can run next to the nodes after it, until the first node that takes it }; struct ggml_custom_kernel { diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 76bdcd2a2c..28c74d83f7 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -6302,6 +6302,10 @@ void ggml_custom_sched_set_group_size(struct ggml_custom_sched * sched, int n0, sched->group_size[2] = n2; } +void ggml_custom_sched_set_async(struct ggml_custom_sched * sched, bool async) { + sched->async = async; +} + struct ggml_tensor * ggml_custom_op_4d( struct ggml_context * ctx, enum ggml_type type,