From d863f725a1181b98c5d3faeb9f7659c3dfcc7bc1 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 13 Sep 2023 22:51:10 +0300 Subject: [PATCH] coreml : add code to toggle Core ML config (CPU, ANE, GPU) --- coreml/whisper-encoder.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coreml/whisper-encoder.mm b/coreml/whisper-encoder.mm index 6cd90edf..69c1484c 100644 --- a/coreml/whisper-encoder.mm +++ b/coreml/whisper-encoder.mm @@ -22,7 +22,13 @@ struct whisper_coreml_context * whisper_coreml_init(const char * path_model) { NSURL * url_model = [NSURL fileURLWithPath: path_model_str]; - const void * data = CFBridgingRetain([[whisper_encoder_impl alloc] initWithContentsOfURL:url_model error:nil]); + // select which device to run the Core ML model on + MLModelConfiguration *config = [[MLModelConfiguration alloc] init]; + //config.computeUnits = MLComputeUnitsCPUAndGPU; + config.computeUnits = MLComputeUnitsCPUAndNeuralEngine; + //config.computeUnits = MLComputeUnitsAll; + + const void * data = CFBridgingRetain([[whisper_encoder_impl alloc] initWithContentsOfURL:url_model configuration:config error:nil]); if (data == NULL) { return NULL;