Remove deprecated "mobile" packages (#20941)

# Description

This PR removes the building of the ORT "mobile" packages and much of the associated infrastructure which is no longer needed.

Not removed yet - tools/ci_build/github/android/mobile_package.required_operators.config and the helper scripts that depend on it.

# Motivation and Context

The mobile packages were deprecated in 1.18. Users should use the full packages (Android - onnxruntime-android, iOS - onnxruntime-c/onnxruntime-objc) instead or do a custom build.
This commit is contained in:
Edward Chen 2024-06-07 16:20:32 -05:00 committed by GitHub
parent a53f692832
commit 981893c318
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 68 additions and 273 deletions

View file

@ -231,7 +231,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Android")
set(ANDROID_TEST_PACKAGE_LIB_DIR ${ANDROID_TEST_PACKAGE_DIR}/app/libs)
file(MAKE_DIRECTORY ${ANDROID_TEST_PACKAGE_LIB_DIR})
# Copy the built Android AAR package to libs folder of our test app
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ANDROID_PACKAGE_OUTPUT_DIR}/outputs/aar/onnxruntime-debug.aar ${ANDROID_TEST_PACKAGE_LIB_DIR}/onnxruntime-mobile.aar)
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ANDROID_PACKAGE_OUTPUT_DIR}/outputs/aar/onnxruntime-debug.aar ${ANDROID_TEST_PACKAGE_LIB_DIR}/onnxruntime-android.aar)
# Build Android test apk for java package
add_custom_command(TARGET onnxruntime4j_jni
POST_BUILD

View file

@ -7,9 +7,7 @@ def headersDir = System.properties['headersDir']
def publishDir = System.properties['publishDir']
def minSdkVer = System.properties['minSdkVer']
def targetSdkVer = System.properties['targetSdkVer']
def buildVariant = System.properties['buildVariant'] ?: "Full"
boolean enableTrainingApis = (System.properties['ENABLE_TRAINING_APIS'] ?: "0") == "1"
boolean isMobileBuild = (buildVariant == "Mobile")
// Since Android requires a higher numbers indicating more recent versions
// This function assume ORT version number will be in formart of A.B.C such as 1.7.0
@ -28,17 +26,10 @@ project.version = rootProject.file('../VERSION_NUMBER').text.trim()
project.group = "com.microsoft.onnxruntime"
def tmpArtifactId = enableTrainingApis ? project.name + "-training" : project.name
def mavenArtifactId = isMobileBuild ? tmpArtifactId + '-mobile' : tmpArtifactId + '-android'
def mobileDescription = 'The ONNX Runtime Mobile package is a size optimized inference library for executing ONNX ' +
'(Open Neural Network Exchange) models on Android. This package is built from the open source inference engine ' +
'but with reduced disk footprint targeting mobile platforms. To minimize binary size this library supports a ' +
'reduced set of operators and types aligned to typical mobile applications. The ONNX model must be converted to ' +
'ORT format in order to use it with this package. ' +
'See https://onnxruntime.ai/docs/reference/ort-format-models.html for more details.'
def mavenArtifactId = tmpArtifactId + '-android'
def defaultDescription = 'ONNX Runtime is a performance-focused inference engine for ONNX (Open Neural Network ' +
'Exchange) models. This package contains the Android (aar) build of ONNX Runtime. It includes support for all ' +
'types and operators, for ONNX format models. All standard ONNX models can be executed with this package. ' +
'As such the binary size and memory usage will be larger than the onnxruntime-mobile package.'
'types and operators, for ONNX format models. All standard ONNX models can be executed with this package.'
def trainingDescription = 'The onnxruntime-training android package is designed to efficiently train and infer a ' +
'wide range of ONNX models on edge devices, such as mobile phones, tablets, and other portable devices with ' +
'a focus on minimizing resource usage and maximizing accuracy.' +
@ -147,7 +138,7 @@ publishing {
pom {
name = enableTrainingApis ? 'onnxruntime-training' : 'onnx-runtime'
description = isMobileBuild ? mobileDescription : enableTrainingApis ? trainingDescription : defaultDescription
description = enableTrainingApis ? trainingDescription : defaultDescription
url = 'https://microsoft.github.io/onnxruntime/'
licenses {
license {

View file

@ -44,7 +44,7 @@ dependencies {
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation(name: "onnxruntime-mobile", ext: "aar")
implementation(name: "onnxruntime-android", ext: "aar")
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'

View file

@ -286,7 +286,9 @@ Prior to ORT v1.13, the ONNX Runtime React Native package utilized the ONNX Runt
Follow these [instructions](https://onnxruntime.ai/docs/reference/ort-format-models.html#convert-onnx-models-to-ort-format) to convert ONNX model to ORT format.
Note that the ONNX Runtime Mobile package includes a reduced set of operators and types, so not all models are supported. See [here](https://onnxruntime.ai/docs/reference/operators/MobileOps.html) for the list of supported operators and types.
From ORT v1.13 onwards the 'full' ONNX Runtime package is used. It supports both ONNX and ORT format models, and all operators and types.
From ORT v1.13 onwards, the 'full' ONNX Runtime package is used. It supports both ONNX and ORT format models, and all operators and types.
From ORT v1.19 onwards, the ONNX Runtime Mobile packages are no longer published.
### Build
@ -298,35 +300,24 @@ From ORT v1.13 onwards the 'full' ONNX Runtime package is used. It supports both
2. Acquire or build the Android ONNX Runtime package
1. To use a published Android ONNX Runtime Mobile package from Maven, go to step 5.
1. To use a published Android ONNX Runtime package from Maven, go to step 5.
2. Set up an Android build environment using these [instructions](https://onnxruntime.ai/docs/build/android.html). Note that the dependencies are quite convoluted, so using the specified JDK and Gradle versions is important.
3. In `<ORT_ROOT>`, run the below python script to build the ONNX Runtime Android archive file. On a Windows machine, this requires an admin account to build.
You can build a 'full' package that supports all operators and types, or a reduced size 'mobile' package that supports a limited set of operators and types based on your model/s to miminize the binary size.
You can build a 'full' package that supports all operators and types, or a reduced size package that supports a limited set of operators and types based on your model/s to miminize the binary size.
See [here](https://onnxruntime.ai/docs/build/custom.html) for information about how the reduced build works, including creating the configuration file using your model/s.
Full build:
The instructions here show how to build a 'full' package.
```sh
python tools/ci_build/github/android/build_aar_package.py tools/ci_build/github/android/default_full_aar_build_settings.json --config Release --android_sdk_path <ANDROID_SDK_PATH> --android_ndk_path <ANDROID_NDK_PATH> --build_dir <BUILD_DIRECTORY>
```
Reduced size build with configuration file generated from your model/s. Note that either Release or MinSizeRel could be used as the config, depending on your priorities:
```sh
python tools/ci_build/github/android/build_aar_package.py tools/ci_build/github/android/default_mobile_aar_build_settings.json --config MinSizeRel --android_sdk_path <ANDROID_SDK_PATH> --android_ndk_path <ANDROID_NDK_PATH> --build_dir <BUILD_DIRECTORY> --include_ops_by_config <required_ops_and_types_for_your_models.config> --enable_reduced_operator_type_support
```
4. Move the generated ONNX Runtime Android archive file to `<ORT_ROOT>/js/react_native/android/libs/`.
Full build:
Copy `<BUILD_DIRECTORY>/aar_out/Release/com/microsoft/onnxruntime/onnxruntime-android/<version>/onnxruntime-android-<version>.aar` into `<ORT_ROOT>/js/react_native/android/libs` directory.
Reduced size build:
Copy `<BUILD_DIRECTORY>/aar_out/MinSizeRel/com/microsoft/onnxruntime/onnxruntime-mobile/<version>/onnxruntime-mobile-<version>.aar` into `<ORT_ROOT>/js/react_native/android/libs` directory and update to dependencies in [js/react_native/android/build.gradle](https://github.com/microsoft/onnxruntime/blob/365a01397dbd1293e0c2773380c57fd271432b72/js/react_native/android/build.gradle#L136-L137) to use onnxruntime-mobile instead of onnxruntime-android.
5. To verify, open the Android Emulator and run this command from `<ORT_ROOT>/js/react_native/android`
```sh
@ -339,42 +330,20 @@ From ORT v1.13 onwards the 'full' ONNX Runtime package is used. It supports both
2. Set up iOS build environment using these [instructions](https://onnxruntime.ai/docs/build/ios.html).
3. Build a fat ONNX Runtime Mobile Framework for iOS and iOS simulator from `<ORT_ROOT>` using this command:
Full build:
3. Build a fat ONNX Runtime Framework for iOS and iOS simulator from `<ORT_ROOT>` using this command:
```sh
python tools/ci_build/github/apple/build_apple_framework.py tools/ci_build/github/apple/default_full_apple_framework_build_settings.json --config Release
```
Reduced size build:
```sh
python tools/ci_build/github/apple/build_apple_framework.py tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json --config MinSizeRel --include_ops_by_config <required_ops_and_types_for_your_models.config> --enable_reduced_operator_type_support
```
The build creates `Headers`, `LICENSE`, and `onnxruntime.xcframework` in `build/iOS_framework/framework_out` directory. From `framework_out` directory, create an archive file named `onnxruntime-c.zip` for a full build or `onnxruntime-mobile-c.zip` for a reduced size build and copy to `<ORT_ROOT>/js/react_native/local_pods` directory.
Full build:
The build creates `Headers`, `LICENSE`, and `onnxruntime.xcframework` in `build/iOS_framework/framework_out` directory. From `framework_out` directory, create an archive file named `onnxruntime-c.zip` and copy to `<ORT_ROOT>/js/react_native/local_pods` directory.
```sh
zip -r onnxruntime-c.zip .
```
Reduced size build:
```sh
zip -r onnxruntime-mobile-c.zip .
```
4. To verify, open the iOS Simulator and run the below command from `<ORT_ROOT>/js/react_native/ios`. Change the destination argument as needed to specify a running iOS Simulator.
If using the reduced size build it is necessary to first update some configuration to use the mobile ORT package:
- replace `onnxruntime/onnxruntime.framework` with `onnxruntime-mobile/onnxruntime.framework` in /js/react_native/ios/OnnxruntimeModule.xcodeproj/project.pbxproj
- replace `onnxruntime-c` with `onnxruntime-mobile-c` in /js/react_native/ios/Podfile
- For reference, [this PR](https://github.com/microsoft/onnxruntime/pull/13037) shows the changes made to switch from using the 'mobile' ORT package to the 'full' package.
```sh
pod install
xcodebuild test -workspace OnnxruntimeModule.xcworkspace -scheme OnnxruntimeModuleTest -destination 'platform=iOS Simulator,OS=latest,name=iPhone 13'
@ -394,14 +363,9 @@ From ORT v1.13 onwards the 'full' ONNX Runtime package is used. It supports both
yarn bootstrap
```
When testing with a custom built ONNX Runtime Android package, copy `<BUILD_DIRECTORY>/aar_out/MinSizeRel/com/microsoft/onnxruntime/onnxruntime-{android|mobile}/<version>/onnxruntime-{android|mobile}-<version>.aar` into the `<ORT_ROOT>/js/react_native/e2e/android/app/libs` directory.
When testing with a custom built ONNX Runtime Android package, copy `<BUILD_DIRECTORY>/aar_out/MinSizeRel/com/microsoft/onnxruntime/onnxruntime-android/<version>/onnxruntime-android-<version>.aar` into the `<ORT_ROOT>/js/react_native/e2e/android/app/libs` directory.
When testing with a custom built ONNX Runtime iOS package, copy `onnxruntime-[mobile-]c.zip` into the `<ORT_ROOT>/js/react_native/local_pods` directory.
If using the reduced size build it is necessary to update some configuration to use the mobile ORT package:
- replace `com.microsoft.onnxruntime:onnxruntime-android` with `com.microsoft.onnxruntime:onnxruntime-mobile` in /js/react_native/e2e/android/app/build.gradle
- replace `onnxruntime-c` with `onnxruntime-mobile-c` in /js/react_native/e2e/ios/Podfile
When testing with a custom built ONNX Runtime iOS package, copy `onnxruntime-c.zip` into the `<ORT_ROOT>/js/react_native/local_pods` directory.
- Run E2E Testing with Detox framework

View file

@ -229,8 +229,6 @@ dependencies {
androidTestImplementation "com.linkedin.dexmaker:dexmaker-mockito-inline-extended:2.28.1"
// Mobile build:
// implementation "com.microsoft.onnxruntime:onnxruntime-mobile:latest.integration@aar"
implementation "com.microsoft.onnxruntime:onnxruntime-android:latest.integration@aar"
// By default it will just include onnxruntime full aar package

View file

@ -187,7 +187,7 @@ repositories {
dependencies {
androidTestImplementation('com.wix:detox:20.7.0')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
@ -220,8 +220,6 @@ dependencies {
implementation project(':onnxruntime-react-native')
// specify ORT dependency here so it can be found in libs flatDir repository
implementation "com.microsoft.onnxruntime:onnxruntime-android:latest.integration@aar"
// Mobile build:
// implementation "com.microsoft.onnxruntime:onnxruntime-mobile:latest.integration@aar"
}
// Run this once to be able to run the application with BUCK

View file

@ -10,13 +10,6 @@ target 'OnnxruntimeModuleExample' do
use_frameworks!
# Mobile build:
# ort_mobile_c_local_pod_path = ENV['ORT_MOBILE_C_LOCAL_POD_PATH']
# if ort_mobile_c_local_pod_path != nil
# print 'Using onnxruntime-c pod at ', ort_mobile_c_local_pod_path, "\n"
# pod 'onnxruntime-mobile-c', :path => ort_mobile_c_local_pod_path
# end
ort_c_local_pod_path = ENV['ORT_C_LOCAL_POD_PATH']
if ort_c_local_pod_path != nil
print 'Using onnxruntime-c pod at ', ort_c_local_pod_path, "\n"

View file

@ -10,15 +10,6 @@ def shared
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Mobile build
# ort_mobile_c_local_pod_path = ENV['ORT_MOBILE_C_LOCAL_POD_PATH']
# if ort_mobile_c_local_pod_path != nil
# print 'Using onnxruntime-c pod at ', ort_mobile_c_local_pod_path, "\n"
# pod 'onnxruntime-mobile-c', :path => ort_mobile_c_local_pod_path
# else
# pod 'onnxruntime-mobile-c'
# end
ort_c_local_pod_path = ENV['ORT_C_LOCAL_POD_PATH']
if ort_c_local_pod_path != nil

View file

@ -1,14 +1,3 @@
def include_macos_target
if '@C_POD_NAME@' != 'onnxruntime-mobile-c'
if ENV['SKIP_MACOS_TEST'] != 'true'
return true
else
return false
end
end
return false
end
target 'ios_package_test' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
@ -21,7 +10,7 @@ target 'ios_package_test' do
end
end
if include_macos_target
if ENV['SKIP_MACOS_TEST'] != 'true'
target 'macos_package_test' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

View file

@ -11,8 +11,6 @@ import subprocess
import sys
SCRIPT_DIR = pathlib.Path(__file__).parent.resolve()
DEFAULT_OPS_CONFIG_RELATIVE_PATH = "tools/ci_build/github/android/mobile_package.required_operators.config"
DEFAULT_BUILD_SETTINGS_RELATIVE_PATH = "tools/ci_build/github/android/default_mobile_aar_build_settings.json"
def is_windows():
@ -53,16 +51,18 @@ def parse_args():
parser.add_argument(
"--include_ops_by_config",
type=pathlib.Path,
help="The configuration file specifying which ops to include. "
help="The optional configuration file specifying which ops to include. "
"Such a configuration file is generated during ONNX to ORT format model conversion. "
f"The default is {DEFAULT_OPS_CONFIG_RELATIVE_PATH} in the ONNX Runtime repo.",
"When providing this option, consider also enabling op type support reduction by specifying "
"the build.py --enable_reduced_operator_type_support option in the build settings configuration file.",
)
parser.add_argument(
"--build_settings",
type=pathlib.Path,
required=True,
help="The configuration file specifying the build.py options. "
f"The default is {DEFAULT_BUILD_SETTINGS_RELATIVE_PATH} in the ONNX Runtime repo.",
"For an example, see tools/ci_build/github/android/default_full_aar_build_settings.json.",
)
default_config = "Release"
@ -95,6 +95,12 @@ def parse_args():
args = parser.parse_args()
if not args.build_settings.is_file():
raise ValueError(f"--build_settings argument is not a file: {args.build_settings}")
if args.include_ops_by_config is not None and not args.include_ops_by_config.is_file():
raise ValueError(f"--include_ops_by_config argument is not a file: {args.include_ops_by_config}")
if args.docker_path is None:
raise ValueError("Unable to determine docker path. Please provide it with --docker_path.")
@ -129,7 +135,7 @@ def main():
working_dir.mkdir(parents=True, exist_ok=True)
working_dir = working_dir.resolve()
# copy over any custom build configuration files
# copy over custom build configuration files
config_files = [f for f in [args.include_ops_by_config, args.build_settings] if f]
if config_files:
input_dir = working_dir / "input"
@ -141,16 +147,10 @@ def main():
output_dir.mkdir(exist_ok=True)
container_ops_config_file = (
f"/workspace/shared/input/{args.include_ops_by_config.name}"
if args.include_ops_by_config
else f"/workspace/onnxruntime/{DEFAULT_OPS_CONFIG_RELATIVE_PATH}"
f"/workspace/shared/input/{args.include_ops_by_config.name}" if args.include_ops_by_config else None
)
container_build_settings_file = (
f"/workspace/shared/input/{args.build_settings.name}"
if args.build_settings
else f"/workspace/onnxruntime/{DEFAULT_BUILD_SETTINGS_RELATIVE_PATH}"
)
container_build_settings_file = f"/workspace/shared/input/{args.build_settings.name}"
# enable use of Ctrl-C to stop when running interactively
docker_run_interactive_args = ["-it"] if sys.stdin.isatty() else []
@ -165,11 +165,13 @@ def main():
"/bin/bash",
"/workspace/scripts/build.sh",
args.config,
container_ops_config_file,
container_build_settings_file,
"/workspace/shared/output",
container_build_settings_file,
]
if container_ops_config_file is not None:
docker_container_build_cmd += [container_ops_config_file]
run(docker_container_build_cmd)
print("Finished building Android package at '{}'.".format(output_dir / "aar_out"))

View file

@ -6,21 +6,29 @@
set -e -x
USAGE_TEXT="Usage: ${0} <build config> <ops config file> <build settings file> <output directory>"
USAGE_TEXT="Usage: ${0} <build config> <output directory> <build settings file> [<ops config file>]"
BUILD_CONFIG=${1:?${USAGE_TEXT}}
OPS_CONFIG_FILE=${2:?${USAGE_TEXT}}
OUTPUT_DIR=${2:?${USAGE_TEXT}}
BUILD_SETTINGS_FILE=${3:?${USAGE_TEXT}}
OUTPUT_DIR=${4:?${USAGE_TEXT}}
OPS_CONFIG_FILE=${4} # optional input
# build in directory that is not shared with the host to avoid permissions issues and speed up file access
BUILD_DIR=/workspace/build
# build ORT AAR
python3 /workspace/onnxruntime/tools/ci_build/github/android/build_aar_package.py \
--build_dir="${BUILD_DIR}" \
--config="${BUILD_CONFIG}" \
--include_ops_by_config="${OPS_CONFIG_FILE}" \
"${BUILD_SETTINGS_FILE}"
if [[ -n "${OPS_CONFIG_FILE}" ]]; then
python3 /workspace/onnxruntime/tools/ci_build/github/android/build_aar_package.py \
--build_dir="${BUILD_DIR}" \
--config="${BUILD_CONFIG}" \
--include_ops_by_config="${OPS_CONFIG_FILE}" \
"${BUILD_SETTINGS_FILE}"
else
python3 /workspace/onnxruntime/tools/ci_build/github/android/build_aar_package.py \
--build_dir="${BUILD_DIR}" \
--config="${BUILD_CONFIG}" \
"${BUILD_SETTINGS_FILE}"
fi
# copy AAR to output directory
cp -r "${BUILD_DIR}/aar_out" "${OUTPUT_DIR}"

View file

@ -2002,7 +2002,8 @@ def run_ios_tests(args, source_dir, config, cwd):
"--framework_info_file",
framework_info_file,
"--variant",
"Mobile",
"Full",
"--skip_macos_test",
],
cwd=cwd,
)
@ -2016,7 +2017,8 @@ def run_ios_tests(args, source_dir, config, cwd):
"--framework_info_file",
framework_info_file,
"--variant",
"Mobile",
"Full",
"--skip_macos_test",
],
cwd=cwd,
)

View file

@ -14,7 +14,6 @@ SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
REPO_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, "..", "..", "..", ".."))
BUILD_PY = os.path.join(REPO_DIR, "tools", "ci_build", "build.py")
JAVA_ROOT = os.path.join(REPO_DIR, "java")
DEFAULT_BUILD_VARIANT = "Full"
sys.path.insert(0, os.path.join(REPO_DIR, "tools", "python"))
from util import is_windows # noqa: E402
@ -72,7 +71,6 @@ def _parse_build_settings(args):
)
build_settings["build_params"] = build_params
build_settings["build_variant"] = build_settings_data.get("build_variant", DEFAULT_BUILD_VARIANT)
return build_settings
@ -148,7 +146,6 @@ def _build_aar(args):
"-DpublishDir=" + aar_publish_dir,
"-DminSdkVer=" + str(build_settings["android_min_sdk_version"]),
"-DtargetSdkVer=" + str(build_settings["android_target_sdk_version"]),
"-DbuildVariant=" + str(build_settings["build_variant"]),
(
"-DENABLE_TRAINING_APIS=1"
if "--enable_training_apis" in build_settings["build_params"]
@ -167,7 +164,7 @@ def parse_args():
os.path.basename(__file__),
description="""Create Android Archive (AAR) package for one or more Android ABI(s)
and building properties specified in the given build config file, see
tools/ci_build/github/android/default_mobile_aar_build_settings.json for details.
tools/ci_build/github/android/default_full_aar_build_settings.json for details.
The output of the final AAR package can be found under [build_dir]/aar_out
""",
)

View file

@ -1,25 +0,0 @@
{
"build_abis": [
"armeabi-v7a",
"arm64-v8a",
"x86",
"x86_64"
],
"android_min_sdk_version": 21,
"android_target_sdk_version": 24,
"build_variant": "Mobile",
"build_params": [
"--android",
"--parallel",
"--cmake_generator=Ninja",
"--build_java",
"--build_shared_lib",
"--minimal_build=extended",
"--disable_rtti",
"--disable_ml_ops",
"--disable_exceptions",
"--enable_reduced_operator_type_support",
"--use_nnapi",
"--skip_tests"
]
}

View file

@ -52,7 +52,7 @@ def parse_args():
parser.add_argument(
"--variant",
choices=PackageVariant.release_variant_names(),
default=PackageVariant.Mobile.name,
default=PackageVariant.Full.name,
help="Pod package variant.",
)

View file

@ -26,8 +26,6 @@ def get_pod_config_file(package_variant: PackageVariant):
"""
if package_variant == PackageVariant.Full:
return _script_dir / "onnxruntime-c.config.json"
elif package_variant == PackageVariant.Mobile:
return _script_dir / "onnxruntime-mobile-c.config.json"
elif package_variant == PackageVariant.Training:
return _script_dir / "onnxruntime-training-c.config.json"
else:

View file

@ -1,5 +0,0 @@
{
"name": "onnxruntime-mobile-c",
"summary": "ONNX Runtime Mobile C/C++ Pod",
"description": "A pod for the ONNX Runtime Mobile C/C++ library. This library supports a reduced set of opsets, ops, and types and only supports ORT format models in order to reduce binary size."
}

View file

@ -103,8 +103,6 @@ def get_pod_config_file(package_variant: PackageVariant):
"""
if package_variant == PackageVariant.Full:
return _script_dir / "onnxruntime-objc.config.json"
elif package_variant == PackageVariant.Mobile:
return _script_dir / "onnxruntime-mobile-objc.config.json"
elif package_variant == PackageVariant.Training:
return _script_dir / "onnxruntime-training-objc.config.json"
else:
@ -184,7 +182,7 @@ def parse_args():
parser.add_argument(
"--staging-dir",
type=pathlib.Path,
default=pathlib.Path("./onnxruntime-mobile-objc-staging"),
default=pathlib.Path("./objc-staging"),
help="Path to the staging directory for the Objective-C pod files.",
)
parser.add_argument("--pod-version", required=True, help="Objective-C pod version.")

View file

@ -1,5 +0,0 @@
{
"name": "onnxruntime-mobile-objc",
"summary": "ONNX Runtime Mobile Objective-C Pod",
"description": "A pod for the ONNX Runtime Mobile Objective-C API. The underlying ONNX Runtime library supports a reduced set of opsets, ops, and types and only supports ORT format models in order to reduce binary size."
}

View file

@ -15,8 +15,7 @@ repo_root = _script_dir.parents[3]
class PackageVariant(enum.Enum):
Full = 0 # full ORT build with all opsets, ops, and types
Mobile = 1 # minimal ORT build with reduced ops
Training = 2 # full ORT build with all opsets, ops, and types, plus training APIs
Training = 1 # full ORT build with all opsets, ops, and types, plus training APIs
@classmethod
def release_variant_names(cls):

View file

@ -195,7 +195,7 @@ def _test_apple_packages(args):
cwd=target_proj_path,
)
if PackageVariant[args.variant] != PackageVariant.Mobile and not args.skip_macos_test:
if not args.skip_macos_test:
subprocess.run(
[
"xcrun",

View file

@ -25,12 +25,12 @@ This will do a custom build and create the pod package files for it in `/path/to
Next, update the Podfile to use the local pods:
```diff
- pod 'onnxruntime-mobile-objc'
+ pod 'onnxruntime-mobile-objc', :path => "/path/to/staging/dir/onnxruntime-mobile-objc"
+ pod 'onnxruntime-mobile-c', :path => "/path/to/staging/dir/onnxruntime-mobile-c"
- pod 'onnxruntime-objc'
+ pod 'onnxruntime-objc', :path => "/path/to/staging/dir/onnxruntime-objc"
+ pod 'onnxruntime-c', :path => "/path/to/staging/dir/onnxruntime-c"
```
Note:
The `onnxruntime-mobile-objc` pod depends on the `onnxruntime-mobile-c` pod.
If the released `onnxruntime-mobile-objc` pod is used, this dependency is automatically handled.
However, if a local `onnxruntime-mobile-objc` pod is used, the local `onnxruntime-mobile-c` pod that it depends on also needs to be specified in the Podfile.
The `onnxruntime-objc` pod depends on the `onnxruntime-c` pod.
If the released `onnxruntime-objc` pod is used, this dependency is automatically handled.
However, if a local `onnxruntime-objc` pod is used, the local `onnxruntime-c` pod that it depends on also needs to be specified in the Podfile.

View file

@ -406,6 +406,7 @@ stages:
script: |
"$(Build.SourcesDirectory)/tools/android_custom_build/build_custom_android_package.py" \
--docker_image_tag=$(dockerImageTag) \
--build_settings="$(Build.SourcesDirectory)/tools/ci_build/github/android/default_full_aar_build_settings.json" \
"$(Build.BinariesDirectory)/custom_android_package"
workingDirectory: '$(Build.BinariesDirectory)'

View file

@ -10,7 +10,6 @@ parameters:
default: ''
- name: packageName
# now we can build onnxruntime-android or onnxruntime-mobile for Android, need specify it here
displayName: Package Name
type: string
default: 'onnxruntime-android'
@ -62,7 +61,7 @@ jobs:
cp -av $(Build.SourcesDirectory)/java/src/test/android ./
cd ./android
mkdir -p app/libs
cp $(Build.BinariesDirectory)/final-android-aar/${{parameters.packageName}}-$(OnnxRuntimeVersion).aar app/libs/onnxruntime-mobile.aar
cp $(Build.BinariesDirectory)/final-android-aar/${{parameters.packageName}}-$(OnnxRuntimeVersion).aar app/libs/onnxruntime-android.aar
$(Build.SourcesDirectory)/java/gradlew --no-daemon clean connectedDebugAndroidTest --stacktrace
displayName: Run E2E test using Emulator
workingDirectory: $(Build.BinariesDirectory)

View file

@ -36,7 +36,6 @@ parameters:
default: 'onnxruntime-Ubuntu2204-AMD-CPU'
- name: packageName
# now we can build onnxruntime or onnxruntime-mobile for Android, need specify it here
displayName: Package Name
type: string
default: 'onnxruntime-android'

View file

@ -61,24 +61,6 @@ stages:
BuildId: ${{ parameters.BuildId }}
DoEsrp: ${{ parameters.DoEsrp }}
- stage: Android_Java_API_AAR_Packaging_Mobile
dependsOn: []
jobs:
- template: android-java-api-aar.yml
parameters:
buildConfig: 'Release'
buildSettings: '$(Build.SourcesDirectory)/tools/ci_build/github/android/default_mobile_aar_build_settings.json'
includedOpsConfig: '$(Build.SourcesDirectory)/tools/ci_build/github/android/mobile_package.required_operators.config'
artifactName: 'onnxruntime-android-mobile-aar'
job_name_suffix: 'Mobile'
packageName: 'onnxruntime-mobile'
- template: android-java-api-aar-test.yml
parameters:
artifactName: 'onnxruntime-android-mobile-aar'
job_name_suffix: 'Mobile'
packageName: 'onnxruntime-mobile'
- stage: Android_Java_API_AAR_Packaging_Full
dependsOn: []
jobs:

View file

@ -33,11 +33,6 @@ stages:
- template: android-java-api-aar.yml
parameters:
buildConfig: '${{parameters.BuildConfig}}'
# Mobile build:
# buildSettings: '$(Build.SourcesDirectory)/tools/ci_build/github/js/react_native_e2e_mobile_aar_build_settings.json'
# includedOpsConfig: '$(Build.SourcesDirectory)/tools/ci_build/github/android/mobile_package.required_operators.config'
# artifactName: 'onnxruntime-android-mobile-aar'
# packageName: 'onnxruntime-mobile'
buildSettings: '$(Build.SourcesDirectory)/tools/ci_build/github/js/react_native_e2e_full_aar_build_settings.json'
artifactName: 'onnxruntime-android-full-aar'
job_name_suffix: 'For_React_Native'
@ -83,14 +78,6 @@ stages:
--staging-dir "$(Build.BinariesDirectory)/staging" \
--variant Full \
--build-settings-file $(Build.SourcesDirectory)/tools/ci_build/github/js/react_native_e2e_full_ios_framework_build_settings.json
# Mobile build:
# python $(Build.SourcesDirectory)/tools/ci_build/github/apple/build_and_assemble_apple_pods.py \
# --build_dir $(Build.BinariesDirectory)/ios_framework_mobile \
# --staging-dir "$(Build.BinariesDirectory)/staging" \
# --include_ops_by_config $(Build.SourcesDirectory)/tools/ci_build/github/android/mobile_package.required_operators.config \
# --variant Mobile \
# --build-settings-file $(Build.SourcesDirectory)/tools/ci_build/github/js/react_native_e2e_mobile_ios_framework_build_settings.json
displayName: Build iOS package and assemble pods
env:
CC: clang
@ -104,8 +91,6 @@ stages:
inputs:
targetPath: '$(Build.BinariesDirectory)/staging'
artifact: 'onnxruntime-ios-full-pod'
# Mobile build:
# artifact: 'onnxruntime-ios-mobile-pod'
- stage: ReactNative_CI
displayName: React Native CI
@ -162,18 +147,12 @@ stages:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
# Mobile build:
# artifactName: 'onnxruntime-android-mobile-aar'
# targetPath: '$(Build.BinariesDirectory)/android-mobile-aar'
artifactName: 'onnxruntime-android-full-aar'
targetPath: '$(Build.BinariesDirectory)/android-full-aar'
displayName: Download Android AAR artifacts
- task: CopyFiles@2
inputs:
# Mobile build:
# sourceFolder: $(Build.BinariesDirectory)/android-mobile-aar
# contents: onnxruntime-mobile-*.aar
sourceFolder: $(Build.BinariesDirectory)/android-full-aar
contents: onnxruntime-android-*.aar
targetFolder: $(Build.SourcesDirectory)/js/react_native/android/libs
@ -182,9 +161,6 @@ stages:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
# Mobile build:
# artifactName: 'onnxruntime-ios-mobile-pod'
# targetPath: '$(Build.BinariesDirectory)/ios-mobile-pod'
artifactName: 'onnxruntime-ios-full-pod'
targetPath: '$(Build.BinariesDirectory)/ios-full-pod'
displayName: Download iOS pod artifacts
@ -224,16 +200,12 @@ stages:
displayName: Bootstrap Android and iOS e2e tests
- script: |
# Mobile build:
# ORT_MOBILE_C_LOCAL_POD_PATH=$(Build.BinariesDirectory)/ios-mobile-pod/onnxruntime-mobile-c \
ORT_C_LOCAL_POD_PATH=$(Build.BinariesDirectory)/ios-full-pod/onnxruntime-c \
pod install
workingDirectory: '$(Build.SourcesDirectory)/js/react_native/ios'
displayName: Pod install for onnxruntime react native ios bridge library
- script: |
# Mobile build:
# ORT_MOBILE_C_LOCAL_POD_PATH=$(Build.BinariesDirectory)/ios-mobile-pod/onnxruntime-mobile-c \
ORT_C_LOCAL_POD_PATH=$(Build.BinariesDirectory)/ios-full-pod/onnxruntime-c \
pod install
workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e/ios'
@ -252,9 +224,6 @@ stages:
- task: CopyFiles@2
inputs:
# Mobile build:
# sourceFolder: $(Build.BinariesDirectory)/android-mobile-aar
# contents: onnxruntime-mobile-*.aar
sourceFolder: $(Build.BinariesDirectory)/android-full-aar
contents: onnxruntime-*.aar
targetFolder: $(Build.SourcesDirectory)/js/react_native/e2e/android/app/libs

View file

@ -4,7 +4,6 @@
],
"android_min_sdk_version": 21,
"android_target_sdk_version": 24,
"build_variant": "Full",
"build_params": [
"--android",
"--parallel",

View file

@ -1,22 +0,0 @@
{
"build_abis": [
"x86_64"
],
"android_min_sdk_version": 21,
"android_target_sdk_version": 24,
"build_variant": "Mobile",
"build_params": [
"--android",
"--parallel",
"--cmake_generator=Ninja",
"--build_java",
"--build_shared_lib",
"--minimal_build=extended",
"--disable_rtti",
"--disable_ml_ops",
"--disable_exceptions",
"--enable_reduced_operator_type_support",
"--use_nnapi",
"--skip_tests"
]
}

View file

@ -1,25 +0,0 @@
{
"build_osx_archs": {
"iphonesimulator": [
"x86_64"
]
},
"build_params": {
"base": [
"--parallel",
"--use_xcode",
"--build_apple_framework",
"--minimal_build=extended",
"--disable_rtti",
"--disable_ml_ops",
"--disable_exceptions",
"--enable_reduced_operator_type_support",
"--use_coreml",
"--skip_tests"
],
"iphonesimulator": [
"--ios",
"--apple_deploy_target=13.0"
]
}
}