allocate work buffer as a ggml_object in ggml_graph_compute_with_ctx

This commit is contained in:
slaren 2023-07-25 20:35:59 +02:00
parent 59e808b49b
commit 567b5e24ed

5
ggml.c
View file

@ -16576,10 +16576,9 @@ void ggml_graph_reset(struct ggml_cgraph * cgraph) {
void ggml_graph_compute_with_ctx(struct ggml_context * ctx, struct ggml_cgraph * cgraph, int n_threads) { void ggml_graph_compute_with_ctx(struct ggml_context * ctx, struct ggml_cgraph * cgraph, int n_threads) {
struct ggml_cplan cplan = ggml_graph_plan(cgraph, n_threads); struct ggml_cplan cplan = ggml_graph_plan(cgraph, n_threads);
struct ggml_tensor * buf = ggml_new_tensor_1d(ctx, GGML_TYPE_I8, cplan.work_size); struct ggml_object * obj = ggml_new_object(ctx, GGML_OBJECT_WORK_BUFFER, cplan.work_size);
GGML_ASSERT(buf);
cplan.work_data = buf->data; cplan.work_data = (uint8_t *)ctx->mem_buffer + obj->offs;
ggml_graph_compute(cgraph, &cplan); ggml_graph_compute(cgraph, &cplan);
} }