Skip to content

Commit b4a79e6

Browse files
authored
Merge branch 'master' into java-api
2 parents 5b42825 + 41fc820 commit b4a79e6

File tree

7 files changed

+82
-22
lines changed

7 files changed

+82
-22
lines changed

BUILD.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ The complete list of build options can be found by running `./build.sh (or .\bui
9999
* [Intel DNNL/MKL-ML](#DNNL-and-MKLML)
100100
* [Intel nGraph](#nGraph)
101101
* [Intel OpenVINO](#openvino)
102-
* [Android NNAPI](#Android)
102+
* [Android NNAPI](#Android-NNAPI)
103103
* [Nuphar Model Compiler](#Nuphar)
104104
* [DirectML](#DirectML)
105105
@@ -111,6 +111,7 @@ The complete list of build options can be found by running `./build.sh (or .\bui
111111
**Architectures**
112112
* [x86](#x86)
113113
* [ARM](#ARM)
114+
* [Android](#Android)
114115
115116
---
116117
@@ -276,18 +277,9 @@ For more information on OpenVINO Execution Provider's ONNX Layer support, To
276277
277278
---
278279
279-
### Android
280-
281-
#### Cross compiling on Linux
282-
283-
1. Get Android NDK from https://developer.android.com/ndk/downloads. Please unzip it after downloading.
280+
### Android NNAPI
284281
285-
2. Get a pre-compiled protoc from [here](https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip). Please unzip it after downloading.
286-
287-
3. Denote the unzip destination in step 1 as $ANDROID_NDK, append `-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DONNX_CUSTOM_PROTOC_EXECUTABLE=path/to/protoc` to your cmake args, run cmake and make to build it.
288-
289-
#### Notes
290-
* For 32-bit devices, replace `-DANDROID_ABI=arm64-v8a` with `-DANDROID_ABI=armeabi-v7a`.
282+
See information on the NNAPI Execution Provider [here](./docs/execution_providers/NNAPI-ExecutionProvider.md).
291283
292284
---
293285
@@ -540,3 +532,27 @@ ls -l /code/onnxruntime/build/Linux/MinSizeRel/dist/*.whl
540532

541533
2. Use `.\build.bat` and specify `--arm` or `--arm64` as the build option to start building. Preferably use `Developer Command Prompt for VS` or make sure all the installed cross-compilers are findable from the command prompt being used to build using the PATH environmant variable.
542534

535+
---
536+
537+
### Android
538+
539+
#### Pre-Requisites
540+
541+
Install Android NDK from https://developer.android.com/ndk/downloads
542+
543+
#### Build Instructions
544+
545+
##### Cross compiling on Windows
546+
547+
```bash
548+
./build.bat --android --android_ndk_path <android ndk path> --android_abi <android abi, e.g., arm64-v8a (default) or armeabi-v7a> --android_api <android api level, e.g., 27 (default)>
549+
```
550+
551+
##### Cross compiling on Linux
552+
553+
```bash
554+
./build.sh --android --android_ndk_path <android ndk path> --android_abi <android abi, e.g., arm64-v8a (default) or armeabi-v7a> --android_api <android api level, e.g., 27 (default)>
555+
```
556+
557+
If you want to use NNAPI Execution Provider on Android, see [docs/execution_providers/NNAPI-ExecutionProvider.md](/docs/execution_providers/NNAPI-ExecutionProvider.md).
558+

cmake/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ else()
279279
add_library(protobuf::libprotobuf ALIAS libprotobuf-lite)
280280
endif()
281281
add_executable(protobuf::protoc ALIAS protoc)
282+
283+
if(UNIX AND onnxruntime_ENABLE_LTO)
284+
#https://github.com/protocolbuffers/protobuf/issues/5923
285+
target_link_options(protoc PRIVATE "-Wl,--no-as-needed")
286+
endif()
287+
282288
include(protobuf_function.cmake)
283289

284290
if (onnxruntime_DISABLE_CONTRIB_OPS)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# NNAPI Execution Provider
2+
3+
[Android Neural Networks API (NNAPI)](https://developer.android.com/ndk/guides/neuralnetworks) is a unified interface to CPU, GPU, and NN accelerators on Android. It is supported by onnxruntime via [DNNLibrary](https://github.com/JDAI-CV/DNNLibrary).
4+
5+
## Minimum requirements
6+
7+
The NNAPI EP requires Android devices with Android 8.1 or higher.
8+
9+
## Build NNAPI EP
10+
11+
### Pre-Requisites
12+
13+
To build onnxruntime with NNAPI EP, install Android NDK first (see [BUILD.md](/BUILD.md#android))
14+
15+
### Build Instructions
16+
17+
The basic commands are following. There are also some other parameters for building the Android version. See [BUILD.md](/BUILD.md#android) for the details.
18+
19+
#### Cross compiling on Windows
20+
21+
```bash
22+
./build.bat --android --android_ndk_path <android ndk path> --dnnlibrary
23+
```
24+
25+
#### Cross compiling on Linux
26+
27+
```bash
28+
./build.sh --android --android_ndk_path <android ndk path> --dnnlibrary
29+
```
30+
31+
## Using NNAPI EP in C/C++
32+
33+
To use NNAPI EP for inferencing, please register it as below.
34+
```
35+
InferenceSession session_object{so};
36+
session_object.RegisterExecutionProvider(std::make_unique<::onnxruntime::NnapiExecutionProvider>());
37+
status = session_object.Load(model_file_name);
38+
```
39+
The C API details are [here](../C_API.md#c-api).
40+
41+
## Performance
42+
43+
![NNAPI EP on RK3399](./images/nnapi-ep-rk3399.png)
44+
45+
![NNAPI EP on OnePlus 6T](./images/nnapi-ep-oneplus6t.png)
46+
47+
![NNAPI EP on Huawei Honor V10](./images/nnapi-ep-huaweihonorv10.png)
Loading
Loading
Loading

tools/ci_build/github/azure-pipelines/win-ci-pipeline.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ jobs:
3333
arguments: '--config $(BuildConfig) --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --update --cmake_generator "Visual Studio 16 2019" --build_wheel --use_automl --use_dnnl --use_openmp --build_shared_lib --enable_onnx_tests --build_java'
3434
workingDirectory: '$(Build.BinariesDirectory)'
3535

36-
# - task: BatchScript@1
37-
# displayName: 'Add PATH to build directory'
38-
# inputs:
39-
# filename: '$(Build.SourcesDirectory)\tools\ci_build\github\windows\set_path_to_build_dir.bat'
40-
# arguments: '$(Build.BinariesDirectory)\$(BuildConfig)\$(BuildConfig)'
41-
# modifyEnvironment: true
42-
# workingFolder: '$(Build.BinariesDirectory)'
43-
4436
- task: VSBuild@1
4537
displayName: 'Build'
4638
inputs:
@@ -79,7 +71,6 @@ jobs:
7971
displayName: 'setup env'
8072
inputs:
8173
filename: '$(Build.SourcesDirectory)\tools\ci_build\github\windows\$(EnvSetupScript)'
82-
# arguments: '$(Build.BinariesDirectory)\$(BuildConfig)\$(BuildConfig)'
8374
modifyEnvironment: true
8475
workingFolder: '$(Build.BinariesDirectory)'
8576

@@ -121,7 +112,7 @@ jobs:
121112
set /p WHEEL_FILENAME=<wheel_filename_file
122113
del wheel_filename_file
123114
python.exe -m pip install -q --upgrade %WHEEL_FILENAME%
124-
set PATH=%PATH%;$(Build.BinariesDirectory)\$(BuildConfig)\$(BuildConfig)
115+
set PATH=%PATH%;$(Build.BinariesDirectory)\$(BuildConfig)\$(BuildConfig)
125116
python $(Build.SourcesDirectory)\tools\ci_build\build.py --config $(BuildConfig) --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --test --cmake_generator "Visual Studio 16 2019" --use_dnnl --build_wheel --enable_onnx_tests
126117
127118
workingDirectory: '$(Build.BinariesDirectory)\$(BuildConfig)\$(BuildConfig)'

0 commit comments

Comments
 (0)