Skip to content

Commit

Permalink
Merge pull request #13 from GoodNotes/paco/ci_build_67bc9438d
Browse files Browse the repository at this point in the history
[AANT-3779][AANT-3799] Upgrade ONNXRuntime to v1.19 and support Hanwang HWR
  • Loading branch information
pacowong authored Oct 21, 2024
2 parents d8b475e + ef04ce3 commit 0deaf27
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 30 deletions.
58 changes: 58 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: 2.1
parameters:
xcode-version:
type: string
default: "15.4.0"
macos-resource-class:
type: string
default: macos.m1.medium.gen1

# Jobs -------------------------------------------------------------------------
jobs:
build-and-test-xcframework:
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 with build_apple_framework.py
command: |
export PYTHONPATH=${CIRCLE_WORKING_DIRECTORY}/tools/python:$PYTHONPATH
python3 ${CIRCLE_WORKING_DIRECTORY}/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=${CIRCLE_WORKING_DIRECTORY}/tools/ci_build/github/apple/hws_mobile_package.required_operators.config \
${CIRCLE_WORKING_DIRECTORY}/tools/ci_build/github/apple/default_full_ios_framework_build_settings.json
- run:
name: archive the build results
command: |
tar -cvf /Users/distiller/project/onnxruntime_xcf.tar -C $HOME/onnxlibrary/macabi_release_v20230327_2320/framework_out .
- store_artifacts:
path: /Users/distiller/project/onnxruntime_xcf.tar
destination: onnxruntime_xcf.tar
workflows:
version: 2
build-and-test-xcframework:
jobs:
- build-and-test-xcframework
105 changes: 79 additions & 26 deletions .github/workflows/generate-xcframework-maccatalyst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ on:
#workflow_dispatch:
# branches: [main, develop]

env:
python_version: 3.11

jobs:
build_macabi_xcf:
runs-on: macos-latest
runs-on: macos-14
env:
xcode_version: 15
steps:
- name: install Python 3.10
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: ${{ env.python_version }}

- name: check Xcode version and Python 3
run: |
Expand All @@ -23,34 +27,83 @@ jobs:
python --version
which python3
# - name: Use Xcode ${{ env.xcode_version }}
# shell: bash
# run: |
# XCODE_DEVELOPER_DIR="/Applications/Xcode_${{ env.xcode_version }}.app/Contents/Developer"
# sudo xcode-select --switch "${XCODE_DEVELOPER_DIR}"

- name: checkout repository
uses: actions/checkout@v3

- name: install protoc
run : |
mkdir -p $HOME/Downloads
cd $HOME/Downloads
curl -LJO https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-osx-universal_binary.zip
unzip protoc-21.12-osx-universal_binary.zip -d protoc-21.12-osx-universal_binary
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/
uses: actions/checkout@v4

# - name: install protoc
# run : |
# mkdir -p $HOME/Downloads
# cd $HOME/Downloads
# curl -LJO https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-osx-universal_binary.zip
# unzip protoc-21.12-osx-universal_binary.zip -d protoc-21.12-osx-universal_binary
# 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 release build
# - name: create release build
# run: |
# # Since Python 3.12, distutils is removed
# # pip3 install setuptools
# export PYTHONPATH=${{ github.workspace }}/tools/python:$PYTHONPATH
# cd ${{ github.workspace }}/tools/python
# ls ${{ github.workspace }}/tools/python
# # pip install -r ${{ github.workspace }}/requirements-dev.txt
# # pip install -r ${{ github.workspace }}/tools/ci_build/requirements.txt
# #Deal with lSystem
# export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
# export LIBRARY_PATH="$LIBRARY_PATH:$SDKROOT/usr/lib"
# #Build command
# python tools/ci_build/github/apple/build_apple_framework.py --config Release --build_dir /Users/goodnotesci/onnxlibrary/ios_release_v20240405_onnx116 --include_ops_by_config tools/ci_build/github/apple/hws_mobile_package.required_operators.config tools/ci_build/github/apple/default_full_ios_framework_build_settings.json

# python ${{ github.workspace }}/tools/ci_build/github/apple/build_apple_framework.py --config=Release --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 \
# --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 releae build
run: |
# Since Python 3.12, distutils is removed
# pip3 install setuptools
export PYTHONPATH=${{ github.workspace }}/tools/python:$PYTHONPATH
cd ${{ github.workspace }}/tools/python
ls ${{ github.workspace }}/tools/python
pip install -r ${{ github.workspace }}/requirements-dev.txt
pip install -r ${{ github.workspace }}/tools/ci_build/requirements.txt
#Deal with lSystem
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export LIBRARY_PATH="$LIBRARY_PATH:$SDKROOT/usr/lib"
#Build command
python ${{ github.workspace }}/tools/ci_build/github/apple/build_macabi_framework.py --config=Release --build_dir=$HOME/onnxlibrary/macabi_release_v20230327_2320 \
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 \
--path_to_protoc_exe=/usr/local/bin/protoc-3.21.12.0 ${{ github.workspace }}/tools/ci_build/github/apple/default_full_macabi_framework_build_settings.json
${{ github.workspace }}/tools/ci_build/github/apple/default_full_ios_framework_build_settings.json
# python ./tools/ci_build/build.py \
# --build_dir $HOME/onnxlibrary/macabi_release_v20230327_2320 \
# --update \
# --build --parallel \
# --test \
# --build_shared_lib \
# --build_objc \
# --use_coreml \
# --use_xnnpack \
# --use_binskim_compliant_compile_flags \
# --include_ops_by_config=${{ github.workspace }}/tools/ci_build/github/apple/default_full_macabi_framework_build_settings.json


- name: create release build 2
run: |
python ./tools/ci_build/build.py \
--build_dir $HOME/onnxlibrary/macabi_release_v20230327_2320 \
--update \
--build --parallel \
--skip_tests \
--build_apple_framework \
--use_xcode \
--use_coreml \
--use_xnnpack \
--use_binskim_compliant_compile_flags \
--ios \
--apple_deploy_target=16.0 \
--apple_sysroot=iphonesimulator \
--osx_arch=x86_64 \
--cmake_extra_defines=onnxruntime_BUILD_UNIT_TESTS=OFF \
--include_ops_by_config=${{ github.workspace }}/tools/ci_build/github/apple/hws_mobile_package.required_operators.config
6 changes: 5 additions & 1 deletion tools/ci_build/github/apple/build_apple_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def _build_for_apple_sysroot(
framework_dir = os.path.join(
build_dir_current_arch,
build_config,
build_config + "-" + sysroot,
(
''
if sysroot == "macabi"
else build_config + "-" + sysroot
),
(
"onnxruntime.framework"
if build_dynamic_framework
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
"--ios",
"--use_xcode",
"--use_xnnpack",
"--apple_deploy_target=13.0"
"--apple_deploy_target=16.6"
],
"iphonesimulator": [
"--ios",
"--use_xcode",
"--use_xnnpack",
"--apple_deploy_target=13.0"
"--apple_deploy_target=16.6"
],
"macabi":[
"--macos=Catalyst",
"--apple_deploy_target=14.0"
"--apple_deploy_target=16.6"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,16 @@ com.microsoft;1;DynamicQuantizeMatMul,FusedConv,FusedGemm,FusedMatMul,Gelu,MatMu
# NHWC transformer also uses this, so assuming it's valuable enough to include
com.microsoft;1;QLinearLeakyRelu

# Hanwang HWR operators
ai.onnx;1;ConvTranspose
ai.onnx;6;Relu
ai.onnx;7;AveragePool
ai.onnx;8;Min,Max
ai.onnx;10;ConvInteger
ai.onnx;11;AveragePool,ConvTranspose,Split,ReduceMin,ReduceMean,ReduceMax,ReduceSum,ReduceProd,Clip,Ceil,Round
com.microsoft;1;DynamicQuantizeLSTM
com.microsoft;1;NhwcConv
com.microsoft.nchwc;1;AveragePool,ReorderInput,Conv,ReorderOutput

# Voice activity detector
ai.onnx;16;Add,Cast,Concat,ConstantOfShape,Conv,Equal,Gather,Identity,If,LSTM,Log,Mul,Neg,Pad,Pow,ReduceMean,Relu,Reshape,Shape,Sigmoid,Slice,Sqrt,Squeeze,Transpose,Unsqueeze

0 comments on commit 0deaf27

Please sign in to comment.