Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback to abort ggml_graph_compute() #328

Merged
merged 13 commits into from
Jul 11, 2023
Prev Previous commit
Next Next commit
return exit status
  • Loading branch information
CCLDArjun committed Jul 3, 2023
commit 4218d926aa9b407d7fef6489c50ceabb86119889
2 changes: 1 addition & 1 deletion include/ggml/ggml.h
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ extern "C" {
GGML_API struct ggml_cgraph ggml_build_backward(struct ggml_context * ctx, struct ggml_cgraph * gf, bool keep);

GGML_API void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph);
GGML_API void ggml_graph_compute_with_abort(struct ggml_context * ctx, struct ggml_cgraph * cgraph, bool (*abort_callback)(void * data), void * abort_callback_data);
GGML_API int ggml_graph_compute_with_abort(struct ggml_context * ctx, struct ggml_cgraph * cgraph, bool (*abort_callback)(void * data), void * abort_callback_data);
GGML_API void ggml_graph_reset (struct ggml_cgraph * cgraph);

GGML_API struct ggml_tensor * ggml_graph_get_tensor(struct ggml_cgraph * cgraph, const char * name);
Expand Down
4 changes: 3 additions & 1 deletion src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -16443,7 +16443,7 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph)
ggml_graph_compute_with_abort(ctx, cgraph, always_false, NULL);
}

void ggml_graph_compute_with_abort(struct ggml_context * ctx, struct ggml_cgraph * cgraph,
int ggml_graph_compute_with_abort(struct ggml_context * ctx, struct ggml_cgraph * cgraph,
bool (*abort_callback)(void * data), void *abort_callback_data) {
const int n_threads = cgraph->n_threads;

Expand Down Expand Up @@ -16861,6 +16861,8 @@ void ggml_graph_compute_with_abort(struct ggml_context * ctx, struct ggml_cgraph
(double) perf_time_us_cur / 1000.0,
(double) cgraph->perf_time_us / 1000.0 / cgraph->perf_runs);
}

return compute_status;
}

void ggml_graph_reset(struct ggml_cgraph * cgraph) {
Expand Down
Loading