Skip to content

Commit

Permalink
add more comments for flag
Browse files Browse the repository at this point in the history
  • Loading branch information
wejoncy committed Dec 6, 2024
1 parent 123a4f0 commit 17d2c4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ static const char* const kCoremlProviderOption_EnableOnSubgraphs = "EnableOnSubg
// This process can affect the model loading time and the prediction latency.
// Use this option to tailor the specialization strategy for your model.
static const char* const kCoremlProviderOption_SpecializationStrategy = "SpecializationStrategy";
// this flag is used to profile coreml computeplan after model compile.
// The profile result includes what hardwares of each ops dispatched to and the estimate excution time.
static const char* const kCoremlProviderOption_ProfileComputePlan = "ProfileComputePlan";
// please refer to https://developer.apple.com/documentation/coreml/mlmodelconfiguration/allowlowprecisionaccumulationongpu
static const char* const kCoremlProviderOption_AllowLowPrecisionAccumulationOnGPU = "AllowLowPrecisionAccumulationOnGPU";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ Status SqueezeOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
std::unique_ptr<Operation> op = model_builder.CreateOperation(node, coreml_op_type);
AddOperationInput(*op, "x", input_defs[0]->Name());

// it's impossible to have empty exes input for unsqueeze
if (!axes.empty()) {
// coreml squeeze op does support negative axes
// coreml supports negative axes
AddOperationInput(*op, "axes", model_builder.AddConstant(op->type(), "axes", AsSpan(axes)));
}
AddOperationOutput(*op, *node.OutputDefs()[0]);
Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/core/providers/coreml/model/model.mm
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ Status GetMLMultiArrayCopyInfo(const MLMultiArray* _Nonnull array,
return Status::OK();
}

// since __clang_major__ >= 15, MLComputePlan is introduced in <CoreML/CoreML.h>
// we define __clang_analyzer__ here is for bypass static analysis
void ProfileComputePlan(NSURL* compileUrl, MLModelConfiguration* config) {
#if defined(__APPLE__) && defined(__clang__) && __clang_major__ >= 15 && !defined(__clang_analyzer__)
if (@available(macOS 14.4, iOS 17.4, *)) {
Expand Down Expand Up @@ -454,6 +456,8 @@ Status Predict(const std::unordered_map<std::string, OnnxTensorData>& inputs,
}

// Set the specialization strategy to FastPrediction for macOS 10.15+
// since __clang_major__ >= 15, optimizationHints is introduced in <CoreML/CoreML.h>
// we define __clang_analyzer__ here is for bypass static analysis
#if defined(__APPLE__) && defined(__clang__) && __clang_major__ >= 15 && !defined(__clang_analyzer__)
if (HAS_COREML8_OR_LATER) {
MLOptimizationHints* optimizationHints = [[MLOptimizationHints alloc] init];
Expand Down

0 comments on commit 17d2c4d

Please sign in to comment.