ggml : async hint for custom op kernels

This commit is contained in:
Aman Gupta 2026-11-25 12:26:44 +08:00
parent 81edc76c8f
commit c6e7d3eae2
3 changed files with 9 additions and 0 deletions

View file

@ -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(

View file

@ -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 {

View file

@ -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,