diff --git a/.circleci/config.yml b/.circleci/config.yml index 788a83e26aa46..e601bfc6f3600 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,8 +66,44 @@ jobs: - store_artifacts: path: /Users/distiller/project/onnxruntime_xcframework.zip destination: onnxruntime_xcframework.zip + + build-and-test-wasm: + macos: + xcode: << pipeline.parameters.xcode-version >> + resource_class: << pipeline.parameters.macos-resource-class >> + + shell: /bin/bash --login -o pipefail + + steps: + - run: + name: check Xcode version and Python 3 + command: | + /usr/bin/xcodebuild -version + python3 --version + python --version + which python3 + echo $CIRCLE_WORKING_DIRECTORY + - checkout + - run: + name: create directory to store the library + command: | + mkdir -p $HOME/onnxlibrary/macabi_release_v20230327_2320 + - run: + name: install tools for build + command: | + brew install cmake + pip install -r ${CIRCLE_WORKING_DIRECTORY}/requirements-dev.txt + - run: + name: build static wasm library + command: | + export PYTHONPATH=${CIRCLE_WORKING_DIRECTORY}/tools/python:$PYTHONPATH + bash ${CIRCLE_WORKING_DIRECTORY}/build.sh --build_wasm_static_lib --enable_wasm_simd --enable_wasm_threads + workflows: version: 2 build-and-test-xcframework: jobs: - build-and-test-xcframework + build-and-test-wasm: + jobs: + - build-and-test-wasm diff --git a/onnxruntime/core/providers/coreml/model/model.mm b/onnxruntime/core/providers/coreml/model/model.mm index 5211b89ec17c6..14eb844670b51 100644 --- a/onnxruntime/core/providers/coreml/model/model.mm +++ b/onnxruntime/core/providers/coreml/model/model.mm @@ -369,8 +369,9 @@ void ProfileComputePlan(NSURL* compileUrl, MLModelConfiguration* config) { #define HAS_COREMLOPTIMIZATIONHINT 0 #endif -API_AVAILABLE_COREML8 +API_AVAILABLE(macos(14.4), ios(17.4), tvos(17.4), watchos(10.4)) void ConfigureOptimizationHints(MLModelConfiguration* config, const CoreMLOptions& coreml_options) { + if (@available(macOS 14.4, iOS 17.4, *)) { #if HAS_COREMLOPTIMIZATIONHINT MLOptimizationHints* optimizationHints = [[MLOptimizationHints alloc] init]; if (coreml_options.UseStrategy("FastPrediction")) { @@ -383,6 +384,7 @@ void ConfigureOptimizationHints(MLModelConfiguration* config, const CoreMLOption // not set } #endif + } } Status CompileOrReadCachedModel(NSURL* modelUrl, const CoreMLOptions& coreml_options, @@ -547,10 +549,12 @@ Status Predict(const std::unordered_map& inputs, } // Set the specialization strategy to FastPrediction for macOS 10.15+ - if (HAS_COREML8_OR_LATER) { - ConfigureOptimizationHints(config, coreml_options_); - } else { - LOGS(logger_, WARNING) << "iOS 17.4+/macOS 14.4+ or later is required to ConfigureOptimizationHints"; + if (@available(macOS 14.4, iOS 17.4, *)) { + if (HAS_COREML8_OR_LATER) { + ConfigureOptimizationHints(config, coreml_options_); + } else { + LOGS(logger_, WARNING) << "iOS 17.4+/macOS 14.4+ or later is required to ConfigureOptimizationHints"; + } } if (coreml_options_.ProfileComputePlan()) { diff --git a/onnxruntime/test/wasm/test_inference.cc b/onnxruntime/test/wasm/test_inference.cc index 0153770e138fb..436275934467a 100644 --- a/onnxruntime/test/wasm/test_inference.cc +++ b/onnxruntime/test/wasm/test_inference.cc @@ -6,7 +6,23 @@ #include "core/session/onnxruntime_cxx_api.h" TEST(WebAssemblyTest, test) { - Ort::Env ort_env; + auto numInterOpsThreads = 4; + auto numIntraOpsThreads = 4; + // OrtThreadingOptions *threadingOptions; + // Ort::SessionOptions sessionOptions; + // sessionOptions.DisablePerSessionThreads(); + // Ort::Env ort_env(threadingOptions, ORT_LOGGING_LEVEL_WARNING, "test"); + + OrtEnv* environment; + OrtThreadingOptions* envOpts = nullptr; + Ort::GetApi().CreateThreadingOptions(&envOpts); + Ort::GetApi().SetGlobalIntraOpNumThreads(envOpts, numIntraOpsThreads); + Ort::GetApi().SetGlobalInterOpNumThreads(envOpts, numInterOpsThreads); + Ort::GetApi().SetGlobalSpinControl(envOpts, 1); + Ort::GetApi().CreateEnvWithGlobalThreadPools(ORT_LOGGING_LEVEL_WARNING, "test", envOpts, &environment); + Ort::Env ort_env = Ort::Env(environment); + + // Ort::Env ort_env; Ort::Session session{ort_env, "testdata/mul_1.onnx", Ort::SessionOptions{nullptr}}; auto memory_info = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU); @@ -39,4 +55,4 @@ TEST(WebAssemblyTest, test) { for (size_t i = 0; i != total_len; ++i) { ASSERT_EQ(expected_data[i], result[i]); } -} \ No newline at end of file +}