]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
metal : create autorelease pool during library build (llama/4970)
authorGeorgi Gerganov <redacted>
Wed, 17 Jan 2024 16:38:39 +0000 (18:38 +0200)
committerGeorgi Gerganov <redacted>
Wed, 17 Jan 2024 19:21:10 +0000 (21:21 +0200)
* metal : create autorelease pool during library build

ggml-ci

* test : simplify

ggml-ci

ggml-metal.m

index 44134d1d92494f66b2f4fc451a4766b2d626242d..4482cb0e8a28d1661de9f5b8f7ccc1486b469b0b 100644 (file)
@@ -306,22 +306,21 @@ static struct ggml_metal_context * ggml_metal_init(int n_cb) {
                 return NULL;
             }
 
-            // dictionary of preprocessor macros
-            NSMutableDictionary * prep = [NSMutableDictionary dictionary];
+            @autoreleasepool {
+                // dictionary of preprocessor macros
+                NSMutableDictionary * prep = [NSMutableDictionary dictionary];
 
 #ifdef GGML_QKK_64
-            prep[@"QK_K"] = @(64);
+                prep[@"QK_K"] = @(64);
 #endif
 
-            MTLCompileOptions* options = [MTLCompileOptions new];
-            options.preprocessorMacros = prep;
+                MTLCompileOptions* options = [MTLCompileOptions new];
+                options.preprocessorMacros = prep;
 
-            //[options setFastMathEnabled:false];
+                //[options setFastMathEnabled:false];
 
-            ctx->library = [ctx->device newLibraryWithSource:src options:options error:&error];
-
-            [options release];
-            [prep release];
+                ctx->library = [ctx->device newLibraryWithSource:src options:options error:&error];
+            }
         }
 
         if (error) {