Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ parameters:
default: "15.4.0"
macos-resource-class:
type: string
default: macos.m1.medium.gen1
default: m4pro.medium

# Jobs -------------------------------------------------------------------------
jobs:
Expand All @@ -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: |
Expand Down
71 changes: 47 additions & 24 deletions .github/workflows/generate-xcframework-maccatalyst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 11 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/linux_training.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,4 +53,4 @@ jobs:
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: sarif-results/cpp.sarif
sarif_file: sarif-results/cpp.sarif
5 changes: 4 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
7 changes: 0 additions & 7 deletions cmake/onnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions cmake/onnxruntime_mlas.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/coreml/model/model.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion tools/ci_build/github/apple/build_apple_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"arm64"
],
"iphonesimulator": [
"arm64",
"x86_64"
"arm64"
],
"macabi": [
"arm64",
Expand Down
16 changes: 15 additions & 1 deletion tools/ci_build/github/azure-pipelines/post-merge-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down
Loading