diff --git a/.circleci/config.yml b/.circleci/config.yml index 788a83e26aa46..7079d89fde062 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ parameters: default: "15.4.0" macos-resource-class: type: string - default: macos.m1.medium.gen1 + default: m4pro.medium # Jobs ------------------------------------------------------------------------- jobs: @@ -25,7 +25,12 @@ jobs: python --version which python3 echo $CIRCLE_WORKING_DIRECTORY - - checkout + - run: + name: checkout repository over HTTPS + command: | + git clone --filter=blob:none https://github.com/GoodNotes/onnxruntime.git . + git fetch --depth=1 origin "${CIRCLE_SHA1}" + git checkout --force "${CIRCLE_SHA1}" - run: name: create directory to store the library command: | diff --git a/.github/workflows/generate-xcframework-maccatalyst.yml b/.github/workflows/generate-xcframework-maccatalyst.yml index ff723db0b467c..25b2b9bb761d9 100644 --- a/.github/workflows/generate-xcframework-maccatalyst.yml +++ b/.github/workflows/generate-xcframework-maccatalyst.yml @@ -11,7 +11,22 @@ env: jobs: build_macabi_xcf: - runs-on: macos-14 + name: build_${{ matrix.variant }}_xcf + strategy: + fail-fast: false + matrix: + include: + - variant: static + build_dir_name: macabi_release_static_v20230327_2320 + build_dynamic_flag: "" + artifact_name: onnxruntime-static.xcframework + zip_name: onnxruntime-static.xcframework.zip + - variant: dynamic + build_dir_name: macabi_release_dynamic_v20230327_2320 + build_dynamic_flag: "--build_dynamic_framework" + artifact_name: onnxruntime.xcframework + zip_name: onnxruntime.xcframework.zip + runs-on: macos-26-xlarge env: xcode_version: 15 steps: @@ -21,7 +36,9 @@ jobs: python-version: ${{ env.python_version }} - name: check Xcode version and Python 3 + shell: bash run: | + set -euxo pipefail /usr/bin/xcodebuild -version python3 --version python --version @@ -45,8 +62,11 @@ jobs: # mv protoc-21.12-osx-universal_binary/bin/protoc /usr/local/bin/protoc-3.21.12.0 # mv protoc-21.12-osx-universal_binary/include/* /usr/local/include/ - - name: create directory to store the library - run: mkdir -p $HOME/onnxlibrary/macabi_release_v20230327_2320 + - name: create directories to store the libraries + shell: bash + run: | + set -euxo pipefail + mkdir -p $HOME/onnxlibrary/${{ matrix.build_dir_name }} # - name: create release build # run: | @@ -67,33 +87,36 @@ jobs: # --include_ops_by_config=${{ github.workspace }}/tools/ci_build/github/apple/hws_mobile_package.required_operators.config \ # --path_to_protoc_exe=/usr/local/bin/protoc-3.21.12.0 ${{ github.workspace }}/tools/ci_build/github/apple/hws_mobile_package.required_operators.config - - name: create release build + - name: create ${{ matrix.variant }} release build + shell: bash run: | - export PYTHONPATH=${{ github.workspace }}/tools/python:$PYTHONPATH + set -euxo pipefail + export PYTHONPATH="${{ github.workspace }}/tools/python:${PYTHONPATH:-}" pip install -r ${{ github.workspace }}/requirements-dev.txt - python3 ${{ github.workspace }}/tools/ci_build/github/apple/build_apple_framework.py --config Release --build_dynamic_framework --build_dir=$HOME/onnxlibrary/macabi_release_v20230327_2320 \ - --include_ops_by_config=${{ github.workspace }}/tools/ci_build/github/apple/hws_mobile_package.required_operators.config \ - ${{ github.workspace }}/tools/ci_build/github/apple/default_full_ios_framework_build_settings.json + for attempt in 1 2 3; do + if python3 ${{ github.workspace }}/tools/ci_build/github/apple/build_apple_framework.py --config Release ${{ matrix.build_dynamic_flag }} --build_dir=$HOME/onnxlibrary/${{ matrix.build_dir_name }} \ + --include_ops_by_config=${{ github.workspace }}/tools/ci_build/github/apple/hws_mobile_package.required_operators.config \ + ${{ github.workspace }}/tools/ci_build/github/apple/default_full_ios_framework_build_settings.json; then + break + fi - - name: verify expected slices - run: | - set -euo pipefail - XCF=$HOME/onnxlibrary/macabi_release_v20230327_2320/framework_out/onnxruntime.xcframework - lipo "$XCF/ios-arm64/onnxruntime.framework/onnxruntime" -verify_arch arm64 - lipo "$XCF/ios-arm64_x86_64-simulator/onnxruntime.framework/onnxruntime" -verify_arch arm64 x86_64 - lipo "$XCF/ios-arm64_x86_64-maccatalyst/onnxruntime.framework/onnxruntime" -verify_arch arm64 x86_64 - test "$(plutil -extract MinimumOSVersion raw "$XCF/ios-arm64/onnxruntime.framework/Info.plist")" = "16.4" - test "$(plutil -extract MinimumOSVersion raw "$XCF/ios-arm64_x86_64-simulator/onnxruntime.framework/Info.plist")" = "16.4" - test "$(plutil -extract MinimumOSVersion raw "$XCF/ios-arm64_x86_64-maccatalyst/onnxruntime.framework/Versions/A/Resources/Info.plist")" = "16.4" + if [ "$attempt" -eq 3 ]; then + exit 1 + fi + + sleep $((attempt * 30)) + done - - name: archive xcframework + - name: archive ${{ matrix.variant }} xcframework + shell: bash run: | - cd $HOME/onnxlibrary/macabi_release_v20230327_2320/framework_out - zip -r -y "${{ github.workspace }}/onnxruntime.xcframework.zip" onnxruntime.xcframework + set -euxo pipefail + cd $HOME/onnxlibrary/${{ matrix.build_dir_name }}/framework_out + zip -r -y "${{ github.workspace }}/${{ matrix.zip_name }}" onnxruntime.xcframework - - name: upload xcframework artifact + - name: upload ${{ matrix.variant }} xcframework artifact uses: actions/upload-artifact@v4 with: - name: onnxruntime.xcframework - path: onnxruntime.xcframework.zip + name: ${{ matrix.artifact_name }} + path: ${{ matrix.zip_name }} if-no-files-found: error diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index cf3bc598d02bb..a8726aaa7497e 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -8,7 +8,7 @@ on: [push, pull_request] jobs: validation: name: "Validation" - runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"] + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: gradle/actions/wrapper-validation@v4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8d966d358de01..46c3e72137559 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,6 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: misspell # Check spellings as well + continue-on-error: true uses: reviewdog/action-misspell@v1 with: github_token: ${{ secrets.github_token }} @@ -26,6 +27,7 @@ jobs: level: info filter_mode: diff_context - name: shellcheck # Static check shell scripts + continue-on-error: true uses: reviewdog/action-shellcheck@v1 with: github_token: ${{ secrets.github_token }} @@ -36,12 +38,14 @@ jobs: lint-python-format: # Required workflow name: Python format - runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"] + runs-on: ubuntu-22.04 permissions: contents: read security-events: write steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v5 with: @@ -63,7 +67,11 @@ jobs: - name: Run lintrunner on all files run: | set +e - if ! lintrunner --force-color --all-files --tee-json=lint.json -v; then + LINTRUNNER_ARGS=(--force-color --tee-json=lint.json -v) + if [ "${{ github.event_name }}" != "pull_request" ]; then + LINTRUNNER_ARGS+=(--all-files) + fi + if ! lintrunner "${LINTRUNNER_ARGS[@]}"; then echo "" echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`. To set up lintrunner locally, see https://github.com/microsoft/onnxruntime/blob/main/docs/Coding_Conventions_and_Standards.md#linting .\e[0m" exit 1 @@ -124,7 +132,7 @@ jobs: lint-js: name: Lint JavaScript - runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"] + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/.github/workflows/linux_training.yml b/.github/workflows/linux_training.yml index d382cdf476283..435c60dd604c9 100644 --- a/.github/workflows/linux_training.yml +++ b/.github/workflows/linux_training.yml @@ -12,6 +12,7 @@ concurrency: jobs: orttraining-linux-ci-pipeline: + if: github.event_name != 'pull_request' runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU"] permissions: actions: read @@ -52,4 +53,4 @@ jobs: - name: Upload SARIF uses: github/codeql-action/upload-sarif@v3 with: - sarif_file: sarif-results/cpp.sarif \ No newline at end of file + sarif_file: sarif-results/cpp.sarif diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5adfad63093bc..8ec2cbe5505c1 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,6 +16,7 @@ env: jobs: Windows-CUDA-12: + if: github.event_name != 'pull_request' runs-on: ["self-hosted", "1ES.Pool=onnxruntime-github-vs2022-mms"] steps: - uses: actions/checkout@v4 @@ -44,7 +45,7 @@ jobs: run: python tools\ci_build\build.py --windows_sdk_version 10.0.22621.0 --enable_training --build_java --config Debug --build_dir D:\b --skip_submodule_sync --build_csharp --update --build --parallel --cmake_generator "Visual Studio 17 2022" --build_shared_lib --enable_pybind --use_cuda --cuda_home=${{ github.workspace }}\cuda_sdk\v12.2 --enable_cuda_profiling --cmake_extra_defines CMAKE_CUDA_ARCHITECTURES=75 Vcpkg: - runs-on: "windows-latest" + runs-on: "windows-2022" steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -103,6 +104,7 @@ jobs: --cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests" env: VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default" + VCPKG_BINARY_SOURCES: "clear" shell: pwsh - name: "Run vcpkg(arm64-windows)" @@ -135,4 +137,5 @@ jobs: --cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests" env: VCPKG_OVERLAY_TRIPLETS: "${{ github.workspace }}/cmake/vcpkg-triplets/default" + VCPKG_BINARY_SOURCES: "clear" shell: pwsh diff --git a/README.md b/README.md index 68dcb304ef5a4..4773d90b03d2d 100644 --- a/README.md +++ b/README.md @@ -69,16 +69,26 @@ or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any addi This project is licensed under the [MIT License](LICENSE). ## Build for Goodnotes +Dynamic XCFramework: ``` -python3 tools/ci_build/github/apple/build_apple_framework.py --config Release --build_dynamic_framework --build_dir ~/Downloads/onnat/onnxlibrary/mac_release_v20230327_2320 --include_ops_by_config tools/ci_build/github/apple/hws_mobile_package.required_operators.config --path_to_protoc_exe /usr/local/bin/protoc tools/ci_build/github/apple/default_full_ios_framework_build_settings.json +python3 tools/ci_build/github/apple/build_apple_framework.py --config Release --build_dynamic_framework --build_dir ~/Downloads/onnat/onnxlibrary/mac_release_dynamic_v20230327_2320 --include_ops_by_config tools/ci_build/github/apple/hws_mobile_package.required_operators.config --path_to_protoc_exe /usr/local/bin/protoc tools/ci_build/github/apple/default_full_ios_framework_build_settings.json ``` -(note there’s a --build_dynamic_framework arg) - -Now you can check +Static XCFramework: +``` +python3 tools/ci_build/github/apple/build_apple_framework.py --config Release --build_dir ~/Downloads/onnat/onnxlibrary/mac_release_static_v20230327_2320 --include_ops_by_config tools/ci_build/github/apple/hws_mobile_package.required_operators.config --path_to_protoc_exe /usr/local/bin/protoc tools/ci_build/github/apple/default_full_ios_framework_build_settings.json +``` +You can distinguish the outputs with `file onnxruntime`: +Dynamic: ``` onnxruntime.framework % file onnxruntime onnxruntime: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64] onnxruntime (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 onnxruntime (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64 ``` - +Static: +``` +onnxruntime.framework % file onnxruntime +onnxruntime: Mach-O universal binary with 2 architectures: [x86_64:current ar archive random library] [arm64] +onnxruntime (for architecture x86_64): current ar archive random library +onnxruntime (for architecture arm64): current ar archive random library +``` diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index e59783a013982..9d6e269b0101b 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -355,13 +355,6 @@ function(print_target_properties tgt) endfunction(print_target_properties) -message(STATUS "++++++++ Paco START") -#print_target_properties(onnxruntime) -MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} ) -MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} ) -message(STATUS "++++++++ Paco END") -#message(FATAL_ERROR get_property(target_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)) - # Assemble the Apple static framework (iOS and macOS) if(onnxruntime_BUILD_APPLE_FRAMEWORK) # when building for mac catalyst, the CMAKE_OSX_SYSROOT is set to MacOSX as well, to avoid duplication, diff --git a/cmake/onnxruntime_mlas.cmake b/cmake/onnxruntime_mlas.cmake index 099b61e90579a..3af41261ddaee 100644 --- a/cmake/onnxruntime_mlas.cmake +++ b/cmake/onnxruntime_mlas.cmake @@ -1,12 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -message(STATUS "++++++++ Paco START onnxruntime_mlas.cmake") -MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} ) -MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} ) -message(STATUS "++++++++ Paco END") - -#message(FATAL_ERROR get_property(target_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)) set(MLAS_ROOT ${ONNXRUNTIME_ROOT}/core/mlas) set(MLAS_SRC_DIR ${MLAS_ROOT}/lib) set(MLAS_INC_DIR ${MLAS_ROOT}/inc) diff --git a/onnxruntime/core/providers/coreml/model/model.mm b/onnxruntime/core/providers/coreml/model/model.mm index c060ca67d500b..0829fd904f92a 100644 --- a/onnxruntime/core/providers/coreml/model/model.mm +++ b/onnxruntime/core/providers/coreml/model/model.mm @@ -369,7 +369,7 @@ void ProfileComputePlan(NSURL* compileUrl, MLModelConfiguration* config) { #define HAS_COREMLOPTIMIZATIONHINT 0 #endif -#if HAS_COREMLOPTIMIZATIONHINT && \ +#if HAS_COREMLOPTIMIZATIONHINT && \ ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000) || \ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000)) #define HAS_COREMLOPTIMIZATIONHINT_SPECIALIZATION_STRATEGY 1 diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 9cab5c21ea2ad..2961200ebd783 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -1370,9 +1370,11 @@ def generate_build_tree( if args.use_dml and not (args.dml_path or args.dml_external_project): raise BuildError("You must set dml_path or dml_external_project when building with the GDK.") + is_maccatalyst = args.macos == "Catalyst" + if is_macOS() and not args.android: cmake_args += ["-DCMAKE_OSX_ARCHITECTURES=" + args.osx_arch] - if args.apple_deploy_target: + if args.apple_deploy_target and not is_maccatalyst: cmake_args += ["-DCMAKE_OSX_DEPLOYMENT_TARGET=" + args.apple_deploy_target] # Code sign the binaries, if the code signing development identity and/or team id are provided if args.xcode_code_signing_identity: @@ -1437,11 +1439,12 @@ def generate_build_tree( cmake_args += [ "-Donnxruntime_BUILD_SHARED_LIB=ON", "-DCMAKE_OSX_SYSROOT=" + args.apple_sysroot, - "-DCMAKE_OSX_DEPLOYMENT_TARGET=" + args.apple_deploy_target, # we do not need protoc binary for ios cross build "-Dprotobuf_BUILD_PROTOC_BINARIES=OFF", "-DPLATFORM_NAME=" + platform_name, ] + if not is_maccatalyst: + cmake_args += ["-DCMAKE_OSX_DEPLOYMENT_TARGET=" + args.apple_deploy_target] if args.ios: cmake_args += [ "-DCMAKE_SYSTEM_NAME=iOS", @@ -1452,7 +1455,12 @@ def generate_build_tree( # https://forums.developer.apple.com/forums/thread/122571 if args.macos == "Catalyst": macabi_target = f"{args.osx_arch}-apple-ios{args.apple_deploy_target}-macabi" - macabi_warn_flags = "-Wno-overriding-option -Wno-deprecated-enum-enum-conversion" + macabi_warn_flags = ( + "-Wno-unknown-warning-option " + "-Wno-overriding-option " + "-Wno-overriding-t-option " + "-Wno-deprecated-enum-enum-conversion" + ) cmake_args += [ "-DCMAKE_CXX_COMPILER_TARGET=" + macabi_target, "-DCMAKE_C_COMPILER_TARGET=" + macabi_target, diff --git a/tools/ci_build/github/apple/build_apple_framework.py b/tools/ci_build/github/apple/build_apple_framework.py index b26a17913a62f..be187443a5b26 100644 --- a/tools/ci_build/github/apple/build_apple_framework.py +++ b/tools/ci_build/github/apple/build_apple_framework.py @@ -47,7 +47,9 @@ def _get_framework_dir(build_dir_current_arch, build_config, sysroot, build_dyna if sysroot == "macabi" and build_dynamic_framework: candidates.append(os.path.join(build_dir_current_arch, build_config, "onnxruntime.framework")) - candidates.append(os.path.join(build_dir_current_arch, build_config, build_config + "-" + sysroot, framework_subdir)) + candidates.append( + os.path.join(build_dir_current_arch, build_config, build_config + "-" + sysroot, framework_subdir) + ) for framework_dir in candidates: if os.path.exists(framework_dir): diff --git a/tools/ci_build/github/apple/default_full_ios_framework_build_settings.json b/tools/ci_build/github/apple/default_full_ios_framework_build_settings.json index 61d048c220f31..60562767cde53 100644 --- a/tools/ci_build/github/apple/default_full_ios_framework_build_settings.json +++ b/tools/ci_build/github/apple/default_full_ios_framework_build_settings.json @@ -4,8 +4,7 @@ "arm64" ], "iphonesimulator": [ - "arm64", - "x86_64" + "arm64" ], "macabi": [ "arm64", diff --git a/tools/ci_build/github/azure-pipelines/post-merge-jobs.yml b/tools/ci_build/github/azure-pipelines/post-merge-jobs.yml index 7dc6ec5747acf..280c9aa0c2d79 100644 --- a/tools/ci_build/github/azure-pipelines/post-merge-jobs.yml +++ b/tools/ci_build/github/azure-pipelines/post-merge-jobs.yml @@ -445,13 +445,27 @@ stages: tools/ci_build/github/apple/test_ios_framework_build_settings.json displayName: "Build iOS dynamic framework" + - script: | + python tools/ci_build/github/apple/build_apple_framework.py \ + --build_dir "$(Build.BinariesDirectory)/ios_framework_static" \ + tools/ci_build/github/apple/test_ios_framework_build_settings.json + displayName: "Build iOS static framework" + - script: | python tools/ci_build/github/apple/test_apple_packages.py \ --framework_info_file "$(Build.BinariesDirectory)/ios_framework/xcframework_info.json" \ --c_framework_dir "$(Build.BinariesDirectory)/ios_framework/framework_out" \ --variant Full \ --skip_macos_test - displayName: "Test pod with iOS framework" + displayName: "Test pod with iOS dynamic framework" + + - script: | + python tools/ci_build/github/apple/test_apple_packages.py \ + --framework_info_file "$(Build.BinariesDirectory)/ios_framework_static/xcframework_info.json" \ + --c_framework_dir "$(Build.BinariesDirectory)/ios_framework_static/framework_out" \ + --variant Full \ + --skip_macos_test + displayName: "Test pod with iOS static framework" - stage: IosMinimalTrainingBuild dependsOn: []