Eliminate alloca from ggml_graph_compute()

It has only 1 exit point (at the end), so adding a single free() is
enough.
This commit is contained in:
Olaf Seibert 2023-04-12 16:35:23 +02:00
parent a0f3de5b84
commit 0260aa67fc

4
ggml.c
View file

@ -9464,7 +9464,7 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph)
/*.has_work =*/ false,
/*.stop =*/ false,
};
struct ggml_compute_state * workers = n_threads > 1 ? alloca(sizeof(struct ggml_compute_state)*(n_threads - 1)) : NULL;
struct ggml_compute_state * workers = n_threads > 1 ? malloc(sizeof(struct ggml_compute_state)*(n_threads - 1)) : NULL;
// create thread pool
if (n_threads > 1) {
@ -9876,6 +9876,8 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph)
(double) perf_time_us_cur / 1000.0,
(double) cgraph->perf_time_us / 1000.0 / cgraph->perf_runs);
}
free(workers);
}
void ggml_graph_reset(struct ggml_cgraph * cgraph) {