Skip to content

Commit

Permalink
[Android NNAPI EP] Remove dependency on external JD/DNNLibrary (#4576)
Browse files Browse the repository at this point in the history
* remove dependency of external jd-dnnlibrary

* remove extra variables not used any more

* update /cgmanifest.json
  • Loading branch information
guoyu-wang committed Jul 22, 2020
1 parent f0edd07 commit c2ec3b7
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 613 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
[submodule "cmake/external/eigen"]
path = cmake/external/eigen
url = https://gitlab.com/libeigen/eigen.git
[submodule "cmake/external/DNNLibrary"]
path = cmake/external/DNNLibrary
url = https://github.com/JDAI-CV/DNNLibrary
[submodule "cmake/external/horovod"]
path = cmake/external/horovod
url = https://github.com/horovod/horovod.git
Expand Down
48 changes: 16 additions & 32 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ DNNL: `./build.sh --use_dnnl`
#### Deprecation Notice

| | |
| --- | --- |
| --- | --- |
| Deprecation Begins | June 1, 2020 |
| Removal Date | December 1, 2020 |

Starting with the OpenVINO™ toolkit 2020.2 release, all of the features previously available through nGraph have been merged into the OpenVINO™ toolkit. As a result, all the features previously available through ONNX RT Execution Provider for nGraph have been merged with ONNX RT Execution Provider for OpenVINO™ toolkit.

Therefore, ONNX RT Execution Provider for **nGraph** will be deprecated starting June 1, 2020 and will be completely removed on December 1, 2020. Users are recommended to migrate to the ONNX RT Execution Provider for OpenVINO™ toolkit as the unified solution for all AI inferencing on Intel® hardware.
Therefore, ONNX RT Execution Provider for **nGraph** will be deprecated starting June 1, 2020 and will be completely removed on December 1, 2020. Users are recommended to migrate to the ONNX RT Execution Provider for OpenVINO™ toolkit as the unified solution for all AI inferencing on Intel® hardware.

See more information on the nGraph Execution Provider [here](./docs/execution_providers/nGraph-ExecutionProvider.md).

Expand Down Expand Up @@ -345,31 +345,6 @@ For more information on OpenVINO Execution Provider's ONNX Layer support, To

---

### Android NNAPI

See more information on the NNAPI Execution Provider [here](./docs/execution_providers/NNAPI-ExecutionProvider.md).

#### Prerequisites

To build ONNX Runtime with the NN API EP, first install Android NDK (see [Android Build instructions](#android))

#### Build Instructions

The basic build commands are below. There are also some other parameters for building the Android version. See [Android Build instructions](#android) for more details.

##### Cross compiling on Windows

```bash
./build.bat --android --android_sdk_path <android sdk path> --android_ndk_path <android ndk path> --use_dnnlibrary
```

##### Cross compiling on Linux

```bash
./build.sh --android --android_sdk_path <android sdk path> --android_ndk_path <android ndk path> --use_dnnlibrary
```
---

### NUPHAR
See more information on the Nuphar Execution Provider [here](./docs/execution_providers/Nuphar-ExecutionProvider.md).

Expand Down Expand Up @@ -983,7 +958,7 @@ Install an NDK version
- NDK path in our example with this install would be `.../Android/ndk/21.1.6352462`
- NOTE: If you install the ndk-bundle package the path will be `.../Android/ndk-bundle` as there's no version number

#### Build Instructions
#### Android Build Instructions

##### Cross compiling on Windows

Expand All @@ -998,14 +973,23 @@ e.g. using the paths from our example
./build.bat --android --android_sdk_path .../Android --android_ndk_path .../Android/ndk/21.1.6352462 --android_abi arm64-v8a --android_api 27 --cmake_generator Ninja
```

##### Cross compiling on Linux
##### Cross compiling on Linux and macOS

```
./build.sh --android --android_sdk_path <android sdk path> --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)>
```
Android Archive (AAR) files, which can be imported directly in Android Studio, will be generated in your_build_dir/java/build/outputs/aar.

If you want to use NNAPI Execution Provider on Android, see [docs/execution_providers/NNAPI-ExecutionProvider.md](/docs/execution_providers/NNAPI-ExecutionProvider.md).
##### Build Android Archive (AAR)

Android Archive (AAR) files, which can be imported directly in Android Studio, will be generated in your_build_dir/java/build/outputs/aar, by using the above building commands with `--build_java`

#### Android NNAPI Execution Provider

If you want to use NNAPI Execution Provider on Android, see [NNAPI Execution Provider](/docs/execution_providers/NNAPI-ExecutionProvider.md).

##### Build Instructions

Android NNAPI Execution Provider can be built using building commands in [Android Build instructions](#android-build-instructions) with `--use_nnapi`

---

Expand All @@ -1014,7 +998,7 @@ If you want to use NNAPI Execution Provider on Android, see [docs/execution_prov
See more information on the MIGraphX Execution Provider [here](./docs/execution_providers/MIGraphX-ExecutionProvider.md).

#### Prerequisites
* Install [ROCM](https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html)
* Install [ROCM](https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html)
* The MIGraphX execution provider for ONNX Runtime is built and tested with ROCM3.3
* Install [MIGraphX](https://github.com/ROCmSoftwarePlatform/AMDMIGraphX)
* The path to MIGraphX installation must be provided via the `--migraphx_home parameter`.
Expand Down
11 changes: 1 addition & 10 deletions cgmanifests/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,6 @@
}
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "647d4c3f4d47d9cf63fb90ec175c414a005adea7",
"repositoryUrl": "https://github.com/JDAI-CV/DNNLibrary.git"
}
}
},
{
"component": {
"Type": "other",
Expand Down Expand Up @@ -308,4 +299,4 @@
}
],
"Version": 1
}
}
120 changes: 0 additions & 120 deletions cgmanifests/submodules/cgmanifest.json
Original file line number Diff line number Diff line change
@@ -1,126 +1,6 @@
{
"Version": 1,
"Registrations": [
{
"component": {
"type": "git",
"git": {
"commitHash": "e17f11e966b2cce7d747799b76bb9843813d4b01",
"repositoryUrl": "https://github.com/JDAI-CV/DNNLibrary"
},
"comments": "git submodule at cmake/external/DNNLibrary"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "9e7e8cbe9f675123dd41b7c62868acad39188cae",
"repositoryUrl": "https://github.com/google/flatbuffers"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/flatbuffers"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "8d7a107d68c127f3f494bb7807b796c8c5a97a82",
"repositoryUrl": "https://github.com/google/glog"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/glog"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "94d238d96e3fb3a7ba34f03c284b9ad3516163be",
"repositoryUrl": "https://github.com/onnx/onnx"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/onnx"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "e776aa0275e293707b6a0901e0e8d8a8a3679508",
"repositoryUrl": "https://github.com/google/benchmark.git"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/onnx/third_party/benchmark"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "a1041190c8b8ff0cd9e2f0752248ad5e3789ea0c",
"repositoryUrl": "https://github.com/pybind/pybind11.git"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/onnx/third_party/pybind11"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "6a00cbc4a9b8e68b71caf7f774b3f9c753ae84d5",
"repositoryUrl": "https://github.com/wjakob/clang-cindex-python3"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/onnx/third_party/pybind11/tools/clang"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "6973c3a5041636c1d8dc5f7f6c8c1f3c15bc63d6",
"repositoryUrl": "https://github.com/google/protobuf/"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/protobuf"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8",
"repositoryUrl": "https://github.com/google/benchmark.git"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/protobuf/third_party/benchmark"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "c3bb0ee2a63279a803aaad956b9b26d74bf9e6e2",
"repositoryUrl": "https://github.com/google/googletest.git"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/protobuf/third_party/googletest"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "9bb3313162c0b856125e481ceece9d8faa567716",
"repositoryUrl": "https://github.com/pybind/pybind11"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/pybind11"
}
},
{
"component": {
"type": "git",
"git": {
"commitHash": "6a00cbc4a9b8e68b71caf7f774b3f9c753ae84d5",
"repositoryUrl": "https://github.com/wjakob/clang-cindex-python3"
},
"comments": "git submodule at cmake/external/DNNLibrary/third_party/pybind11/tools/clang"
}
},
{
"component": {
"type": "git",
Expand Down
9 changes: 2 additions & 7 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ option(onnxruntime_ENABLE_MEMLEAK_CHECKER "Experimental: Enable memory leak chec
option(onnxruntime_USE_CUDA "Build with CUDA support" OFF)
option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
option(onnxruntime_USE_EIGEN_FOR_BLAS "Use eign for blas" ON)
option(onnxruntime_USE_NNAPI_DNNLIBRARY "Build with DNNLibrary for Android NNAPI support" OFF)
option(onnxruntime_USE_NNAPI_BUILTIN "Build with builtin NNAPI lib for Android NNAPI support" OFF)
option(onnxruntime_USE_RKNPU "Build with RKNPU support" OFF)
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
Expand Down Expand Up @@ -199,10 +198,6 @@ if(onnxruntime_ENABLE_LTO)
endif()
endif()

if(onnxruntime_USE_NNAPI_BUILTIN AND onnxruntime_USE_NNAPI_DNNLIBRARY)
message(FATAL_ERROR "Please use only one of onnxruntime_USE_NNAPI_BUILTIN, onnxruntime_USE_NNAPI_DNNLIBRARY")
endif()

if(onnxruntime_DISABLE_RTTI)
add_compile_definitions(ORT_NO_RTTI GOOGLE_PROTOBUF_NO_RTTI)
if(MSVC)
Expand Down Expand Up @@ -924,7 +919,7 @@ if (onnxruntime_USE_TENSORRT)
# needs to link with stdc++fs in Linux
if (NOT APPLE)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES stdc++fs)
endif()
endif()
endif()
endif()

Expand Down Expand Up @@ -998,7 +993,7 @@ if (onnxruntime_ENABLE_TRAINING)
if(NOT DEFINED onnxruntime_MPI_HOME)
execute_process(COMMAND mpirun --version OUTPUT_VARIABLE MPIRUN_OUTPUT)
else()
execute_process(COMMAND ${onnxruntime_MPI_HOME}/bin/mpirun --version OUTPUT_VARIABLE MPIRUN_OUTPUT)
execute_process(COMMAND ${onnxruntime_MPI_HOME}/bin/mpirun --version OUTPUT_VARIABLE MPIRUN_OUTPUT)
endif(NOT DEFINED onnxruntime_MPI_HOME)
string( REGEX MATCH "[0-9]+.[0-9]+.[0-9]" MPI_VERSION ${MPIRUN_OUTPUT})
message( STATUS "MPI Version: ${MPI_VERSION}")
Expand Down
1 change: 0 additions & 1 deletion cmake/external/DNNLibrary
Submodule DNNLibrary deleted from e17f11
2 changes: 1 addition & 1 deletion cmake/onnxruntime_java.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endif()
if (onnxruntime_USE_TENSORRT)
target_compile_definitions(onnxruntime4j_jni PRIVATE USE_TENSORRT=1)
endif()
if (onnxruntime_USE_NNAPI_DNNLIBRARY OR onnxruntime_USE_NNAPI_BUILTIN)
if (onnxruntime_USE_NNAPI_BUILTIN)
target_compile_definitions(onnxruntime4j_jni PRIVATE USE_NNAPI=1)
endif()
if (onnxruntime_USE_NUPHAR)
Expand Down
34 changes: 3 additions & 31 deletions cmake/onnxruntime_providers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if(onnxruntime_USE_TENSORRT)
set(PROVIDERS_TENSORRT onnxruntime_providers_tensorrt)
list(APPEND ONNXRUNTIME_PROVIDER_NAMES tensorrt)
endif()
if(onnxruntime_USE_NNAPI_DNNLIBRARY OR onnxruntime_USE_NNAPI_BUILTIN)
if(onnxruntime_USE_NNAPI_BUILTIN)
set(PROVIDERS_NNAPI onnxruntime_providers_nnapi)
list(APPEND ONNXRUNTIME_PROVIDER_NAMES nnapi)
endif()
Expand Down Expand Up @@ -159,7 +159,7 @@ if (onnxruntime_ENABLE_TRAINING)
if (onnxruntime_USE_HOROVOD)
target_include_directories(onnxruntime_providers PRIVATE ${HOROVOD_INCLUDE_DIRS})
endif()
if (onnxruntime_USE_NCCL OR onnxruntime_USE_HOROVOD)
if (onnxruntime_USE_NCCL OR onnxruntime_USE_HOROVOD)
target_include_directories(onnxruntime_providers PUBLIC ${MPI_INCLUDE_DIRS})
endif()
endif()
Expand Down Expand Up @@ -509,36 +509,8 @@ if (onnxruntime_USE_OPENVINO)

endif()

if (onnxruntime_USE_NNAPI_DNNLIBRARY)
if (onnxruntime_USE_NNAPI_BUILTIN)
add_definitions(-DUSE_NNAPI=1)
add_definitions(-DUSE_NNAPI_DNNLIBRARY=1)
option(DNN_READ_ONNX "" ON)
set(DNN_CUSTOM_PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
option(DNN_CMAKE_INSTALL "" OFF)
option(DNN_BUILD_BIN "" OFF)
add_subdirectory(${REPO_ROOT}/cmake/external/DNNLibrary)
file(GLOB
onnxruntime_providers_nnapi_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/*.cc"
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_dnnlibrary/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_dnnlibrary/*.cc"
)
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_nnapi_cc_srcs})
add_library(onnxruntime_providers_nnapi ${onnxruntime_providers_nnapi_cc_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_nnapi onnxruntime_common onnxruntime_framework onnx onnx_proto protobuf::libprotobuf-lite dnnlibrary::dnnlibrary)
target_link_libraries(onnxruntime_providers_nnapi dnnlibrary::dnnlibrary)
add_dependencies(onnxruntime_providers_nnapi
dnnlibrary::dnnlibrary
onnx ${onnxruntime_EXTERNAL_DEPENDENCIES})
# Header files of DNNLibrary requires C++17, fortunately, all modern Android NDKs support C++17
set_target_properties(onnxruntime_providers_nnapi PROPERTIES CXX_STANDARD 17)
set_target_properties(onnxruntime_providers_nnapi PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(onnxruntime_providers_nnapi PROPERTIES FOLDER "ONNXRuntime")
target_include_directories(onnxruntime_providers_nnapi PRIVATE ${ONNXRUNTIME_ROOT} ${nnapi_INCLUDE_DIRS})
set_target_properties(onnxruntime_providers_nnapi PROPERTIES LINKER_LANGUAGE CXX)
elseif (onnxruntime_USE_NNAPI_BUILTIN)
add_definitions(-DUSE_NNAPI=1)
add_definitions(-DUSE_NNAPI_BUILTIN=1)
file(GLOB
onnxruntime_providers_nnapi_cc_srcs_top CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/*.cc"
Expand Down
9 changes: 3 additions & 6 deletions cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ if (onnxruntime_USE_NGRAPH)
list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_ngraph_src})
endif()

if (onnxruntime_USE_NNAPI_DNNLIBRARY OR onnxruntime_USE_NNAPI_BUILTIN)
if (onnxruntime_USE_NNAPI_BUILTIN)
file(GLOB_RECURSE onnxruntime_test_providers_nnapi_src CONFIGURE_DEPENDS
"${TEST_SRC_DIR}/providers/nnapi/*"
)
Expand Down Expand Up @@ -303,7 +303,7 @@ if(onnxruntime_USE_OPENVINO)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_openvino)
endif()

if(onnxruntime_USE_NNAPI_DNNLIBRARY OR onnxruntime_USE_NNAPI_BUILTIN)
if(onnxruntime_USE_NNAPI_BUILTIN)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_nnapi)
endif()

Expand Down Expand Up @@ -393,7 +393,7 @@ if(onnxruntime_USE_TENSORRT)
list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_tensorrt)
endif()

if(onnxruntime_USE_NNAPI_DNNLIBRARY OR onnxruntime_USE_NNAPI_BUILTIN)
if(onnxruntime_USE_NNAPI_BUILTIN)
list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/nnapi/*)
list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_nnapi)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_nnapi)
Expand Down Expand Up @@ -692,9 +692,6 @@ add_test(NAME onnx_test_pytorch_operator

if (CMAKE_SYSTEM_NAME STREQUAL "Android")
list(APPEND android_shared_libs log android)
if (onnxruntime_USE_NNAPI_DNNLIBRARY)
list(APPEND android_shared_libs neuralnetworks)
endif()
endif()

#perf test runner
Expand Down
Loading

0 comments on commit c2ec3b7

Please sign in to comment.