Add ORT minimal with NNAPI EP to Android CI (#5890)

Description: Add ORT minimal with NNAPI EP to Android CI

Motivation and Context

The added build/test to Android CI will only run UT, additional onnx_test_runner with customer .ort models will be added later
This commit is contained in:
Guoyu Wang 2020-11-23 18:21:34 -08:00 committed by GitHub
parent 916410151c
commit 4137c18d9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 0 deletions

View file

@ -4,9 +4,19 @@ jobs:
vmImage: 'macOS-10.15'
timeoutInMinutes: 120
steps:
# Onnx has no 3.9 python package available yet, need to use python 3.8 to avoid build onnx package
# pythonVersion can be updated in Azure pipeline settings
# https://dev.azure.com/onnxruntime/onnxruntime/_build?definitionId=53
- task: UsePythonVersion@0
displayName: Use Python $(pythonVersion)
inputs:
versionSpec: $(pythonVersion)
- script: brew install coreutils ninja
displayName: Install coreutils and ninja
- script: python3 tools/ci_build/build.py --android --build_dir build --android_sdk_path $ANDROID_HOME --android_ndk_path $ANDROID_HOME/ndk-bundle --android_abi=x86_64 --android_api=29 --skip_submodule_sync --parallel --cmake_generator=Ninja --build_java
displayName: CPU EP, Build and Test on Android Emulator
- script: python3 tools/ci_build/build.py --android --build_dir build_nnapi --android_sdk_path $ANDROID_HOME --android_ndk_path $ANDROID_HOME/ndk-bundle --android_abi=x86_64 --android_api=29 --skip_submodule_sync --parallel --use_nnapi --cmake_generator=Ninja --build_java
displayName: NNAPI EP, Build and Test on Android Emulator
- script: /bin/bash tools/ci_build/github/linux/ort_minimal/nnapi_minimal_build_minimal_ort_and_run_tests.sh $(pwd)
# Build Minimal ORT with NNAPI and reduced Ops, run unit tests on Android Emulator
displayName: Build Minimal ORT with NNAPI and run tests

View file

@ -0,0 +1,58 @@
#!/bin/bash
# This script will run a full ORT build and use the python package built to generate ort format test files,
# and the exclude ops config file, which will be used in the build_minimal_ort_and_run_tests.sh
# This script takes one command line argument, the root of the current Onnx Runtime project
set -e
set -x
ORT_ROOT=$1
MIN_BUILD_DIR=$ORT_ROOT/build_nnapi_minimal
# Remove builds from previous CPU and NNAPI full Android ORT build to free up disk space
rm -rf $ORT_ROOT/build
rm -rf $ORT_ROOT/build_nnapi
# Build with reduced ops requires onnx
python3 -m pip install -U --user onnx
# Copy all the models containing the required ops to pass the UT
mkdir -p $TMPDIR/.test_data/models_to_include
cp $ORT_ROOT/onnxruntime/test/testdata/ort_github_issue_4031.onnx $TMPDIR/.test_data/models_to_include
cp $ORT_ROOT/onnxruntime/test/testdata/mnist.onnx $TMPDIR/.test_data/models_to_include
cp $ORT_ROOT/onnxruntime/test/testdata/ort_minimal_test_models/*.onnx $TMPDIR/.test_data/models_to_include
# Build minimal package for Android x86_64 Emulator
# No test will be triggered in the build process
# UT will be triggered separately below
python3 $ORT_ROOT/tools/ci_build/build.py \
--build_dir $MIN_BUILD_DIR \
--config Debug \
--skip_submodule_sync \
--parallel \
--cmake_generator=Ninja \
--use_nnapi \
--android \
--android_sdk_path $ANDROID_HOME \
--android_ndk_path $ANDROID_HOME/ndk-bundle \
--android_abi=x86_64 \
--android_api=29 \
--minimal_build extended \
--disable_rtti \
--disable_ml_ops \
--disable_exceptions \
--include_ops_by_model $TMPDIR/.test_data/models_to_include/ \
--include_ops_by_config $ORT_ROOT/onnxruntime/test/testdata/reduced_ops_via_config.config \
--skip_tests
# Start the Android Emulator
/bin/bash $ORT_ROOT/tools/ci_build/github/android/start_android_emulator.sh
# Push onnxruntime_test_all and testdata to emulator
adb push $MIN_BUILD_DIR/Debug/onnxruntime_test_all /data/local/tmp/
adb push $MIN_BUILD_DIR/Debug/testdata /data/local/tmp/
# Perform the UT
adb shell 'cd /data/local/tmp/ && ./onnxruntime_test_all'