From 8596bfe7a4b9c2fd12e70559060422a8534bcf19 Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 6 Feb 2026 09:26:35 -0800 Subject: [PATCH 1/7] update objectivec directory from onnxruntime/objectivec --- objectivec/error_utils.mm | 2 +- .../include/ort_coreml_execution_provider.h | 17 +++++++++++++- objectivec/include/ort_enums.h | 1 + objectivec/ort_coreml_execution_provider.mm | 15 +++++++++++++ objectivec/ort_enums.mm | 1 + objectivec/test/ort_session_test.mm | 22 +++++++++++++++++++ objectivec/test/testdata/gen_models.sh | 0 7 files changed, 56 insertions(+), 2 deletions(-) mode change 100644 => 100755 objectivec/test/testdata/gen_models.sh diff --git a/objectivec/error_utils.mm b/objectivec/error_utils.mm index 335cf88..e8d4d5b 100644 --- a/objectivec/error_utils.mm +++ b/objectivec/error_utils.mm @@ -11,7 +11,7 @@ void ORTSaveCodeAndDescriptionToError(int code, const char* descriptionCstr, NSE if (!error) return; NSString* description = [NSString stringWithCString:descriptionCstr - encoding:NSASCIIStringEncoding]; + encoding:NSUTF8StringEncoding]; *error = [NSError errorWithDomain:kOrtErrorDomain code:code diff --git a/objectivec/include/ort_coreml_execution_provider.h b/objectivec/include/ort_coreml_execution_provider.h index d7d873f..41d15aa 100644 --- a/objectivec/include/ort_coreml_execution_provider.h +++ b/objectivec/include/ort_coreml_execution_provider.h @@ -70,7 +70,22 @@ NS_ASSUME_NONNULL_BEGIN */ - (BOOL)appendCoreMLExecutionProviderWithOptions:(ORTCoreMLExecutionProviderOptions*)options error:(NSError**)error; - +/** + * Enables the CoreML execution provider in the session configuration options. + * It is appended to the execution provider list which is ordered by + * decreasing priority. + * + * @param provider_options The CoreML execution provider options in dict. + * available keys-values: more detail in core/providers/coreml/coreml_execution_provider.h + * kCoremlProviderOption_MLComputeUnits: one of "CPUAndNeuralEngine", "CPUAndGPU", "CPUOnly", "All" + * kCoremlProviderOption_ModelFormat: one of "MLProgram", "NeuralNetwork" + * kCoremlProviderOption_RequireStaticInputShapes: "1" or "0" + * kCoremlProviderOption_EnableOnSubgraphs: "1" or "0" + * @param error Optional error information set if an error occurs. + * @return Whether the provider was enabled successfully. + */ +- (BOOL)appendCoreMLExecutionProviderWithOptionsV2:(NSDictionary*)provider_options + error:(NSError**)error; @end NS_ASSUME_NONNULL_END diff --git a/objectivec/include/ort_enums.h b/objectivec/include/ort_enums.h index 78de233..61a127f 100644 --- a/objectivec/include/ort_enums.h +++ b/objectivec/include/ort_enums.h @@ -50,6 +50,7 @@ typedef NS_ENUM(int32_t, ORTGraphOptimizationLevel) { ORTGraphOptimizationLevelNone, ORTGraphOptimizationLevelBasic, ORTGraphOptimizationLevelExtended, + ORTGraphOptimizationLevelLayout, ORTGraphOptimizationLevelAll, }; diff --git a/objectivec/ort_coreml_execution_provider.mm b/objectivec/ort_coreml_execution_provider.mm index 6cb5026..0c790a9 100644 --- a/objectivec/ort_coreml_execution_provider.mm +++ b/objectivec/ort_coreml_execution_provider.mm @@ -43,6 +43,21 @@ BOOL ORTIsCoreMLExecutionProviderAvailable() { #endif } +- (BOOL)appendCoreMLExecutionProviderWithOptionsV2:(NSDictionary*)provider_options + error:(NSError**)error { +#if ORT_OBJC_API_COREML_EP_AVAILABLE + try { + return [self appendExecutionProvider:@"CoreML" providerOptions:provider_options error:error]; + } + ORT_OBJC_API_IMPL_CATCH_RETURNING_BOOL(error); + +#else // !ORT_OBJC_API_COREML_EP_AVAILABLE + static_cast(provider_options); + ORTSaveCodeAndDescriptionToError(ORT_FAIL, "CoreML execution provider is not enabled.", error); + return NO; +#endif +} + @end NS_ASSUME_NONNULL_END diff --git a/objectivec/ort_enums.mm b/objectivec/ort_enums.mm index 6093981..5fcbe34 100644 --- a/objectivec/ort_enums.mm +++ b/objectivec/ort_enums.mm @@ -68,6 +68,7 @@ constexpr GraphOptimizationLevelInfo kGraphOptimizationLevelInfos[]{ {ORTGraphOptimizationLevelNone, ORT_DISABLE_ALL}, {ORTGraphOptimizationLevelBasic, ORT_ENABLE_BASIC}, {ORTGraphOptimizationLevelExtended, ORT_ENABLE_EXTENDED}, + {ORTGraphOptimizationLevelLayout, ORT_ENABLE_LAYOUT}, {ORTGraphOptimizationLevelAll, ORT_ENABLE_ALL}, }; diff --git a/objectivec/test/ort_session_test.mm b/objectivec/test/ort_session_test.mm index 508289f..409ee7e 100644 --- a/objectivec/test/ort_session_test.mm +++ b/objectivec/test/ort_session_test.mm @@ -223,6 +223,28 @@ NS_ASSUME_NONNULL_BEGIN ORTAssertNullableResultSuccessful(session, err); } +- (void)testAppendCoreMLEP_v2 { + NSError* err = nil; + ORTSessionOptions* sessionOptions = [ORTSessionTest makeSessionOptions]; + NSDictionary* provider_options = @{@"EnableOnSubgraphs" : @"1"}; // set an arbitrary option + + BOOL appendResult = [sessionOptions appendCoreMLExecutionProviderWithOptionsV2:provider_options + error:&err]; + + if (!ORTIsCoreMLExecutionProviderAvailable()) { + ORTAssertBoolResultUnsuccessful(appendResult, err); + return; + } + + ORTAssertBoolResultSuccessful(appendResult, err); + + ORTSession* session = [[ORTSession alloc] initWithEnv:self.ortEnv + modelPath:[ORTSessionTest getAddModelPath] + sessionOptions:sessionOptions + error:&err]; + ORTAssertNullableResultSuccessful(session, err); +} + - (void)testAppendXnnpackEP { NSError* err = nil; ORTSessionOptions* sessionOptions = [ORTSessionTest makeSessionOptions]; diff --git a/objectivec/test/testdata/gen_models.sh b/objectivec/test/testdata/gen_models.sh old mode 100644 new mode 100755 From a889626993a4a64913ee8074235cf006066f125a Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 6 Feb 2026 09:47:12 -0800 Subject: [PATCH 2/7] update Package.swift for onnxruntime 1.24.1 --- Package.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index a87c5d0..ffe7f87 100644 --- a/Package.swift +++ b/Package.swift @@ -21,8 +21,8 @@ import class Foundation.ProcessInfo let package = Package( name: "onnxruntime", - platforms: [.iOS(.v13), - .macOS(.v11)], + platforms: [.iOS(.v15), + .macOS(.v14)], products: [ .library(name: "onnxruntime", type: .static, @@ -86,7 +86,6 @@ if let pod_archive_path = ProcessInfo.processInfo.environment["ORT_POD_LOCAL_PAT // See https://onnxruntime.ai/docs/build/custom.html#ios // Example command: // python3 tools/ci_build/github/apple/build_and_assemble_apple_pods.py \ - // --variant Full \ // --build-settings-file tools/ci_build/github/apple/default_full_apple_framework_build_settings.json // // This should produce the pod archive in build/apple_pod_staging, and ORT_POD_LOCAL_PATH can be set to @@ -98,9 +97,9 @@ if let pod_archive_path = ProcessInfo.processInfo.environment["ORT_POD_LOCAL_PAT // ORT release package.targets.append( Target.binaryTarget(name: "onnxruntime", - url: "https://download.onnxruntime.ai/pod-archive-onnxruntime-c-1.23.0.zip", + url: "https://download.onnxruntime.ai/pod-archive-onnxruntime-c-1.24.1.zip", // SHA256 checksum - checksum: "756a78e0168f29840bc614b43aeb03e63673f44022e0221d21698a2c8ed747ef") + checksum: "dab5e98ceba017cfcb74d4a03cc3ab3f0069ede02bc9334ee81ebee310e6e639") ) } From 9f7de3a8ff41566bbc235c4980a42b74bd87c0df Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 6 Feb 2026 11:29:19 -0800 Subject: [PATCH 3/7] update pipelines to use macos-14 image --- .pipelines/mac-ios-spm-extensions-validation-pipeline.yml | 2 +- .pipelines/mac-ios-spm-release-validation-pipeline.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml b/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml index aba313a..a70292b 100644 --- a/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml +++ b/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml @@ -3,7 +3,7 @@ displayName: "Test with ORT Extensions native pod" pool: - vmImage: "macOS-13" + vmImage: "macOS-14" variables: artifactsName: "ios_packaging_artifacts_full" diff --git a/.pipelines/mac-ios-spm-release-validation-pipeline.yml b/.pipelines/mac-ios-spm-release-validation-pipeline.yml index 53d1b12..62a810e 100644 --- a/.pipelines/mac-ios-spm-release-validation-pipeline.yml +++ b/.pipelines/mac-ios-spm-release-validation-pipeline.yml @@ -3,7 +3,7 @@ displayName: "Test with released ORT native pod" pool: - vmImage: "macOS-13" + vmImage: "macOS-14" timeoutInMinutes: 60 From 9130a4ba95bf0eb86da69d398ead8f91bbfcceb9 Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 6 Feb 2026 11:51:00 -0800 Subject: [PATCH 4/7] use xcode 16.2 --- .pipelines/templates/use-xcode-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/templates/use-xcode-version.yml b/.pipelines/templates/use-xcode-version.yml index 0d0a3cd..7298cd9 100644 --- a/.pipelines/templates/use-xcode-version.yml +++ b/.pipelines/templates/use-xcode-version.yml @@ -3,7 +3,7 @@ parameters: - name: xcodeVersion type: string - default: "14.3.1" + default: "16.2" steps: - bash: | From 9705bd4aca5ef2c4f4c89a64fb31b3999b6fccae Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 6 Feb 2026 14:07:09 -0800 Subject: [PATCH 5/7] bump swift-tools-version to 5.9 --- Package.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index ffe7f87..81c5120 100644 --- a/Package.swift +++ b/Package.swift @@ -1,7 +1,5 @@ -// swift-tools-version: 5.6 -// The swift-tools-version declares the minimum version of Swift required to build this package and MUST be the first -// line of this file. 5.6 is required to support zip files for the pod archive binaryTarget. -// +// swift-tools-version: 5.9 + // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // From fdabcd0986451ad9e7dd137c7bf8885830e7fb93 Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 6 Feb 2026 14:40:32 -0800 Subject: [PATCH 6/7] use iPhone 16 simulator for test --- .pipelines/mac-ios-spm-extensions-validation-pipeline.yml | 2 +- .pipelines/mac-ios-spm-release-validation-pipeline.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml b/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml index a70292b..8075a2c 100644 --- a/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml +++ b/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml @@ -87,7 +87,7 @@ cp "$(Build.ArtifactStagingDirectory)/$(artifactsNameForExt)/${POD_ARCHIVE_EXT}" swift/ export ORT_EXTENSIONS_POD_LOCAL_PATH="swift/${POD_ARCHIVE_EXT}" - xcodebuild test -scheme onnxruntime-Package -destination 'platform=iOS Simulator,name=iPhone 14' + xcodebuild test -scheme onnxruntime-Package -destination 'platform=iOS Simulator,name=iPhone 16' xcodebuild test -scheme onnxruntime-Package -destination 'platform=macosx' diff --git a/.pipelines/mac-ios-spm-release-validation-pipeline.yml b/.pipelines/mac-ios-spm-release-validation-pipeline.yml index 62a810e..20b91fc 100644 --- a/.pipelines/mac-ios-spm-release-validation-pipeline.yml +++ b/.pipelines/mac-ios-spm-release-validation-pipeline.yml @@ -14,7 +14,7 @@ # and OnnxRuntimeExtensions targets. - script: | set -e -x - xcodebuild test -scheme onnxruntime-Package -destination 'platform=iOS Simulator,name=iPhone 14' + xcodebuild test -scheme onnxruntime-Package -destination 'platform=iOS Simulator,name=iPhone 16' xcodebuild test -scheme onnxruntime-Package -destination 'platform=macosx' workingDirectory: "$(Build.SourcesDirectory)" displayName: "Test Package.swift usage" From cd42ff1dcabc04146a703917df6e0e45e9d3f74c Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 6 Feb 2026 15:34:46 -0800 Subject: [PATCH 7/7] fix macos platform --- .pipelines/mac-ios-spm-extensions-validation-pipeline.yml | 2 +- .pipelines/mac-ios-spm-release-validation-pipeline.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml b/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml index 8075a2c..086d03c 100644 --- a/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml +++ b/.pipelines/mac-ios-spm-extensions-validation-pipeline.yml @@ -89,7 +89,7 @@ xcodebuild test -scheme onnxruntime-Package -destination 'platform=iOS Simulator,name=iPhone 16' - xcodebuild test -scheme onnxruntime-Package -destination 'platform=macosx' + xcodebuild test -scheme onnxruntime-Package -destination 'platform=macOS' rm swift/pod-archive-onnxruntime-c-*.zip rm swift/pod-archive-onnxruntime-extensions-c-*.zip diff --git a/.pipelines/mac-ios-spm-release-validation-pipeline.yml b/.pipelines/mac-ios-spm-release-validation-pipeline.yml index 20b91fc..4c302a3 100644 --- a/.pipelines/mac-ios-spm-release-validation-pipeline.yml +++ b/.pipelines/mac-ios-spm-release-validation-pipeline.yml @@ -15,7 +15,7 @@ - script: | set -e -x xcodebuild test -scheme onnxruntime-Package -destination 'platform=iOS Simulator,name=iPhone 16' - xcodebuild test -scheme onnxruntime-Package -destination 'platform=macosx' + xcodebuild test -scheme onnxruntime-Package -destination 'platform=macOS' workingDirectory: "$(Build.SourcesDirectory)" displayName: "Test Package.swift usage"