From: Georgi Gerganov Date: Tue, 9 May 2023 15:38:12 +0000 (+0300) Subject: coreml : fix memory leak (#899) X-Git-Tag: upstream/1.7.4~1442 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=1d17cd5bb37a3212679d6055ad69ba5a8d58eb71;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp coreml : fix memory leak (#899) --- diff --git a/coreml/whisper-encoder.mm b/coreml/whisper-encoder.mm index dd08f0f3..49aace8c 100644 --- a/coreml/whisper-encoder.mm +++ b/coreml/whisper-encoder.mm @@ -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 * shape = outMA.shape; - //NSArray * 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