Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wejoncy committed Dec 2, 2024
1 parent 32e08e0 commit 218fe66
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion onnxruntime/core/providers/coreml/model/model.mm
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ Status GetMLMultiArrayCopyInfo(const MLMultiArray* _Nonnull array,
}

void ProfileComputePlan(NSURL* compileUrl, MLModelConfiguration* config) {
#if defined(__APPLE__) && defined(__clang__) && __clang_major__ >= 15
if (@available(macOS 14.4, iOS 17.4, *)) {
[MLComputePlan loadContentsOfURL:compileUrl
configuration:config
Expand Down Expand Up @@ -339,6 +340,7 @@ void ProfileComputePlan(NSURL* compileUrl, MLModelConfiguration* config) {
} else {
NSLog(@"iOS 17.4+/macOS 14.4+ or later is required to use the compute plan API");
}
#endif
}

// Internal Execution class
Expand Down Expand Up @@ -451,7 +453,8 @@ Status Predict(const std::unordered_map<std::string, OnnxTensorData>& inputs,
config.allowLowPrecisionAccumulationOnGPU = YES;
}

// Set the specialization strategy to FastPrediction for macOS 10.15+
// Set the specialization strategy to FastPrediction for macOS 10.15+
#if defined(__APPLE__) && defined(__clang__) && __clang_major__ >= 15
if (HAS_COREML8_OR_LATER) {
MLOptimizationHints* optimizationHints = [[MLOptimizationHints alloc] init];
if (coreml_options_.UseStrategy("FastPrediction")) {
Expand All @@ -462,6 +465,7 @@ Status Predict(const std::unordered_map<std::string, OnnxTensorData>& inputs,
config.optimizationHints = optimizationHints;
}
}
#endif
if (coreml_options_.ProfileComputePlan()) {
ProfileComputePlan(compileUrl, config);
}
Expand Down

0 comments on commit 218fe66

Please sign in to comment.