]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
coreml : fix memory leak (#899)
authorGeorgi Gerganov <redacted>
Tue, 9 May 2023 15:38:12 +0000 (18:38 +0300)
committerGitHub <redacted>
Tue, 9 May 2023 15:38:12 +0000 (18:38 +0300)
coreml/whisper-encoder.mm

index dd08f0f318fa5fcd19913809c890c85ab0bc18b1..49aace8cb1fc97b8b4c39ea563dea7bfcc930587 100644 (file)
@@ -51,15 +51,10 @@ void whisper_coreml_encode(
 
     whisper_encoder_implOutput * outCoreML = [(__bridge id) ctx->data predictionFromLogmel_data:inMultiArray error:nil];
 
-    MLMultiArray * outMA = outCoreML.output;
+    memcpy(out, outCoreML.output.dataPointer, outCoreML.output.count * sizeof(float));
 
-    //NSArray<NSNumber *> * shape = outMA.shape;
-    //NSArray<NSNumber *> * strides = outMA.strides;
-
-    //printf("shape:   %ld %ld %ld %ld\n", [shape[0] longValue], [shape[1] longValue], [shape[2] longValue], [shape[3] longValue]);
-    //printf("strides: %ld %ld %ld %ld\n", [strides[0] longValue], [strides[1] longValue], [strides[2] longValue], [strides[3] longValue]);
-
-    memcpy(out, outMA.dataPointer, outMA.count * sizeof(float));
+    [outCoreML release];
+    [inMultiArray release];
 }
 
 #if __cplusplus