w11wo commited on
Commit
40ed781
β€’
1 Parent(s): 06c45a6

Initialized Repo

Browse files
README.md ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ This repo contains pre-built static onnxruntime libs for iOS using the following
6
+ commit:
7
+
8
+ ```
9
+ commit 62ee0c8110882c6153921c87e36774273fe0a75e (HEAD -> main, github/main)
10
+ Author: Jian Chen <[email protected]>
11
+ Date: Wed Feb 22 19:42:36 2023 -0800
12
+ ```
13
+
14
+ Please see
15
+ https://github.com/k2-fsa/sherpa-onnx
16
+ for its usage.
17
+
18
+
19
+
20
+ # How to build xcframework
21
+
22
+ ```bash
23
+ git clone https://github.com/microsoft/onnxruntime
24
+ cd onnxruntime
25
+ cp ../create-xcframework.sh .
26
+ cp ../run-ios-arm64.sh .
27
+ cp ../run-ios-simulator-arm64.sh .
28
+ cp ../run-ios-simulator-os64.sh .
29
+
30
+ ./run-ios-arm64.sh
31
+ ./run-ios-simulator-arm64.sh
32
+ ./run-ios-simulator-os64.sh
33
+
34
+ ./create-xcframework.sh
35
+ ```
36
+
37
+ You should see the following content:
38
+
39
+ ```bash
40
+ ios-onnxruntime fangjun$ tree onnxruntime.xcframework/
41
+ onnxruntime.xcframework/
42
+ β”œβ”€β”€ Headers
43
+ β”‚Β Β  β”œβ”€β”€ cpu_provider_factory.h
44
+ β”‚Β Β  β”œβ”€β”€ onnxruntime_c_api.h
45
+ β”‚Β Β  β”œβ”€β”€ onnxruntime_cxx_api.h
46
+ β”‚Β Β  └── onnxruntime_cxx_inline.h
47
+ β”œβ”€β”€ Info.plist
48
+ β”œβ”€β”€ ios-arm64
49
+ β”‚Β Β  └── onnxruntime.a
50
+ └── ios-arm64_x86_64-simulator
51
+ └── onnxruntime.a
52
+
53
+ 3 directories, 7 files
54
+ ```
create-xcframework.sh ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
3
+
4
+
5
+ for arch in simulator/os64 simulator/arm64 arm64; do
6
+ libtool -static -o build-ios/$arch/onnxruntime.a \
7
+ build-ios/$arch/Release/static_libraries/libabsl_base.a \
8
+ build-ios/$arch/Release/static_libraries/libabsl_city.a \
9
+ build-ios/$arch/Release/static_libraries/libabsl_hash.a \
10
+ build-ios/$arch/Release/static_libraries/libabsl_low_level_hash.a \
11
+ build-ios/$arch/Release/static_libraries/libabsl_raw_hash_set.a \
12
+ build-ios/$arch/Release/static_libraries/libabsl_raw_logging_internal.a \
13
+ build-ios/$arch/Release/static_libraries/libabsl_throw_delegate.a \
14
+ build-ios/$arch/Release/static_libraries/libclog.a \
15
+ build-ios/$arch/Release/static_libraries/libcpuinfo.a \
16
+ build-ios/$arch/Release/static_libraries/libflatbuffers.a \
17
+ build-ios/$arch/Release/static_libraries/libnsync_cpp.a \
18
+ build-ios/$arch/Release/static_libraries/libonnx.a \
19
+ build-ios/$arch/Release/static_libraries/libonnx_proto.a \
20
+ build-ios/$arch/Release/static_libraries/libonnxruntime_common.a \
21
+ build-ios/$arch/Release/static_libraries/libonnxruntime_coreml_proto.a \
22
+ build-ios/$arch/Release/static_libraries/libonnxruntime_flatbuffers.a \
23
+ build-ios/$arch/Release/static_libraries/libonnxruntime_framework.a \
24
+ build-ios/$arch/Release/static_libraries/libonnxruntime_graph.a \
25
+ build-ios/$arch/Release/static_libraries/libonnxruntime_mlas.a \
26
+ build-ios/$arch/Release/static_libraries/libonnxruntime_optimizer.a \
27
+ build-ios/$arch/Release/static_libraries/libonnxruntime_providers.a \
28
+ build-ios/$arch/Release/static_libraries/libonnxruntime_providers_coreml.a \
29
+ build-ios/$arch/Release/static_libraries/libonnxruntime_session.a \
30
+ build-ios/$arch/Release/static_libraries/libonnxruntime_util.a \
31
+ build-ios/$arch/Release/static_libraries/libprotobuf-lite.a \
32
+ build-ios/$arch/Release/static_libraries/libre2.a
33
+ done
34
+
35
+ lipo -create build-ios/simulator/os64/onnxruntime.a \
36
+ build-ios/simulator/arm64/onnxruntime.a \
37
+ -output build-ios/simulator/onnxruntime.a
38
+
39
+ rm -rf onnxruntime.xcframework
40
+ xcodebuild -create-xcframework \
41
+ -library build-ios/arm64/onnxruntime.a \
42
+ -library build-ios/simulator/onnxruntime.a \
43
+ -output onnxruntime.xcframework
44
+
45
+ mkdir -p onnxruntime.xcframework/Headers
46
+ cp -v ./build-ios/simulator/os64/install/bin/onnxruntime.framework/Headers/*.h onnxruntime.xcframework/Headers
run-ios-arm64.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
3
+
4
+ # https://onnxruntime.ai/docs/build/ios.html
5
+
6
+ num_jobs=3
7
+
8
+ # Get directory this script is in
9
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10
+
11
+
12
+ build_dir=$DIR/build-ios/arm64
13
+
14
+ #requires python3.6 or higher
15
+ python3 \
16
+ $DIR/tools/ci_build/build.py \
17
+ --build_dir $build_dir \
18
+ --config Release \
19
+ --use_xcode \
20
+ --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF \
21
+ --cmake_extra_defines onnxruntime_BUILD_SHARED_LIB=OFF \
22
+ --cmake_extra_defines CMAKE_INSTALL_PREFIX=$build_dir/install/ \
23
+ --ios \
24
+ --ios_sysroot iphoneos \
25
+ --osx_arch arm64 \
26
+ --target install \
27
+ --parallel $num_jobs \
28
+ --skip_tests \
29
+ --build_apple_framework \
30
+ --apple_deploy_target 13.0 \
31
+ --use_coreml
run-ios-simulator-arm64.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ # https://onnxruntime.ai/docs/build/ios.html
4
+
5
+ num_jobs=3
6
+
7
+ # Get directory this script is in
8
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
9
+
10
+
11
+ build_dir=$DIR/build-ios/simulator/arm64
12
+
13
+ #requires python3.6 or higher
14
+ python3 \
15
+ $DIR/tools/ci_build/build.py \
16
+ --build_dir $build_dir \
17
+ --config Release \
18
+ --use_xcode \
19
+ --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF \
20
+ --cmake_extra_defines onnxruntime_BUILD_SHARED_LIB=OFF \
21
+ --cmake_extra_defines CMAKE_INSTALL_PREFIX=$build_dir/install/ \
22
+ --ios \
23
+ --ios_sysroot iphonesimulator \
24
+ --osx_arch arm64 \
25
+ --target install \
26
+ --parallel $num_jobs \
27
+ --skip_tests \
28
+ --build_apple_framework \
29
+ --apple_deploy_target 13.0 \
30
+ --use_coreml
run-ios-simulator-os64.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
3
+
4
+ # https://onnxruntime.ai/docs/build/ios.html
5
+
6
+ num_jobs=3
7
+
8
+ # Get directory this script is in
9
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10
+
11
+
12
+ build_dir=$DIR/build-ios/simulator/os64
13
+
14
+ #requires python3.6 or higher
15
+ python3 \
16
+ $DIR/tools/ci_build/build.py \
17
+ --build_dir $build_dir \
18
+ --config Release \
19
+ --use_xcode \
20
+ --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF \
21
+ --cmake_extra_defines onnxruntime_BUILD_SHARED_LIB=OFF \
22
+ --cmake_extra_defines CMAKE_INSTALL_PREFIX=$build_dir/install/ \
23
+ --ios \
24
+ --ios_sysroot iphonesimulator \
25
+ --osx_arch x86_64 \
26
+ --target install \
27
+ --parallel $num_jobs \
28
+ --skip_tests \
29
+ --build_apple_framework \
30
+ --apple_deploy_target 13.0 \
31
+ --use_coreml