From 5e6358398c073970d5684f7574aba77a271f59d8 Mon Sep 17 00:00:00 2001 From: Paul Tsochantaris Date: Mon, 7 Oct 2024 12:09:16 +0100 Subject: [PATCH] Moving Block_release to the deallocation code --- ggml/src/ggml-metal.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ggml/src/ggml-metal.m b/ggml/src/ggml-metal.m index 40835074b..f1b4b8e87 100644 --- a/ggml/src/ggml-metal.m +++ b/ggml/src/ggml-metal.m @@ -239,8 +239,6 @@ struct ggml_backend_metal_context { struct ggml_cgraph * gf; // the callback given to the thread pool - // TODO: ideally, this should be created once, utilizing the command buffer state above - // for some reason, doing it like this leads to a crash void (^encode_async)(size_t ith); // n_cb command buffers + 1 used by the main thread @@ -438,7 +436,6 @@ static struct ggml_backend_metal_context * ggml_metal_init(void) { ctx->capture_scope = nil; ctx->gf = nil; - Block_release(ctx->encode_async); ctx->encode_async = nil; for (int i = 0; i < GGML_METAL_MAX_COMMAND_BUFFERS; ++i) { ctx->command_buffers[i] = nil; @@ -684,6 +681,8 @@ static void ggml_metal_free(struct ggml_backend_metal_context * ctx) { [ctx->kernels[i].pipeline release]; } + Block_release(ctx->encode_async); + [ctx->queue release]; [ctx->device release];