From ffca096b5a6a65c9fa71915f44d3d49b8fbf036c Mon Sep 17 00:00:00 2001 From: Mauricio A Rovira Galvez <8482308+marovira@users.noreply.github.com> Date: Mon, 30 Sep 2024 23:06:03 -0700 Subject: [PATCH] Fixes a crash on macOS 15 when using CoreML. (#22277) ### Description In macOS 15, apps running with CoreML will crash with an error message like this one: ``` Terminating app due to uncaught exception 'NSGenericException', reason: 'Failed to set compute_device_types_mask E5RT: Cannot provide zero compute device types. (1)' ``` This can be easily seen when building ONNXRuntime from source and running the unit tests. The fix was suggested in [this bug report](https://forums.developer.apple.com/forums/thread/757040). I've ported the change to ONNXRuntime and verified that: * The issue is resolved in macOS 15 (all unit tests pass). * The behaviour is unchanged in macOS 14. ### Motivation and Context This fixes #22275 allowing apps using ONNXRuntime with CoreML to work normally. --- onnxruntime/core/providers/coreml/model/model.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/core/providers/coreml/model/model.mm b/onnxruntime/core/providers/coreml/model/model.mm index 1401cbe95fd56..5f4eebc7d72ce 100644 --- a/onnxruntime/core/providers/coreml/model/model.mm +++ b/onnxruntime/core/providers/coreml/model/model.mm @@ -394,7 +394,7 @@ Status Predict(const std::unordered_map& inputs, compiled_model_path_ = [compileUrl path]; - MLModelConfiguration* config = [MLModelConfiguration alloc]; + MLModelConfiguration* config = [[MLModelConfiguration alloc] init]; config.computeUnits = (coreml_flags_ & COREML_FLAG_USE_CPU_ONLY) ? MLComputeUnitsCPUOnly : MLComputeUnitsAll;