mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-31 23:27:43 +00:00
Make some compile change for Android NNAPI provider using DNNLibrary (#3935)
* Change compile settings for NNAPI with DNNLib * update build.py * update build readme
This commit is contained in:
parent
84c108a85e
commit
cba8bdc790
8 changed files with 27 additions and 30 deletions
4
BUILD.md
4
BUILD.md
|
|
@ -326,13 +326,13 @@ The basic build commands are below. There are also some other parameters for bui
|
|||
##### Cross compiling on Windows
|
||||
|
||||
```bash
|
||||
./build.bat --android --android_sdk_path <android sdk path> --android_ndk_path <android ndk path> --dnnlibrary
|
||||
./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> --dnnlibrary
|
||||
./build.sh --android --android_sdk_path <android sdk path> --android_ndk_path <android ndk path> --use_dnnlibrary
|
||||
```
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ 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 "Build with DNNLibrary for Android NNAPI support" OFF)
|
||||
option(onnxruntime_USE_NNAPI_DNNLIBRARY "Build with DNNLibrary for Android NNAPI support" OFF)
|
||||
option(onnxruntime_USE_RKNPU "Build with RKNPU support" OFF)
|
||||
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
|
||||
option(onnxruntime_USE_MKLML "Build the default cpu provider with MKL-ML binary dependency" OFF)
|
||||
|
|
@ -880,7 +880,7 @@ if (onnxruntime_ENABLE_TRAINING)
|
|||
add_subdirectory(horovod EXCLUDE_FROM_ALL)
|
||||
# use external/horovod/third_party/gloo/cmake/Modules/Findnccl.cmake to locate nccl lib path
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/external/horovod/third_party/gloo/cmake/Modules/)
|
||||
find_package(nccl REQUIRED)
|
||||
find_package(nccl REQUIRED)
|
||||
list(APPEND onnxruntime_EXTERNAL_LIBRARIES horovod ${NCCL_LIBRARIES} ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS})
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ set_source_files_properties(${JAVA_OUTPUT_JAR} PROPERTIES GENERATED TRUE)
|
|||
set_property(TARGET onnxruntime4j APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${JAVA_OUTPUT_DIR}")
|
||||
|
||||
# Specify the native sources
|
||||
file(GLOB onnxruntime4j_native_src
|
||||
file(GLOB onnxruntime4j_native_src
|
||||
"${JAVA_ROOT}/src/main/native/*.c"
|
||||
"${JAVA_ROOT}/src/main/native/*.h"
|
||||
"${REPO_ROOT}/include/onnxruntime/core/session/*.h"
|
||||
|
|
@ -73,7 +73,7 @@ endif()
|
|||
if (onnxruntime_USE_TENSORRT)
|
||||
target_compile_definitions(onnxruntime4j_jni PRIVATE USE_TENSORRT=1)
|
||||
endif()
|
||||
if (onnxruntime_USE_NNAPI)
|
||||
if (onnxruntime_USE_NNAPI_DNNLIBRARY)
|
||||
target_compile_definitions(onnxruntime4j_jni PRIVATE USE_NNAPI=1)
|
||||
endif()
|
||||
if (onnxruntime_USE_NUPHAR)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ if(onnxruntime_USE_TENSORRT)
|
|||
set(PROVIDERS_TENSORRT onnxruntime_providers_tensorrt)
|
||||
list(APPEND ONNXRUNTIME_PROVIDER_NAMES tensorrt)
|
||||
endif()
|
||||
if(onnxruntime_USE_NNAPI)
|
||||
if(onnxruntime_USE_NNAPI_DNNLIBRARY)
|
||||
set(PROVIDERS_NNAPI onnxruntime_providers_nnapi)
|
||||
list(APPEND ONNXRUNTIME_PROVIDER_NAMES nnapi)
|
||||
endif()
|
||||
|
|
@ -461,7 +461,7 @@ if (onnxruntime_USE_OPENVINO)
|
|||
|
||||
endif()
|
||||
|
||||
if (onnxruntime_USE_NNAPI)
|
||||
if (onnxruntime_USE_NNAPI_DNNLIBRARY)
|
||||
add_definitions(-DUSE_NNAPI=1)
|
||||
option(DNN_READ_ONNX "" ON)
|
||||
set(DNN_CUSTOM_PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ if (onnxruntime_USE_NGRAPH)
|
|||
list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_ngraph_src})
|
||||
endif()
|
||||
|
||||
if (onnxruntime_USE_NNAPI)
|
||||
if (onnxruntime_USE_NNAPI_DNNLIBRARY)
|
||||
file(GLOB_RECURSE onnxruntime_test_providers_nnapi_src CONFIGURE_DEPENDS
|
||||
"${TEST_SRC_DIR}/providers/nnapi/*"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ endif()
|
|||
#onnxruntime providers
|
||||
option(onnxruntime_USE_CUDA "Build with CUDA support" OFF)
|
||||
option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
|
||||
option(onnxruntime_USE_NNAPI "Build with DNNLibrary for Android NNAPI support" OFF)
|
||||
option(onnxruntime_USE_NNAPI_DNNLIBRARY "Build with DNNLibrary for Android NNAPI support" OFF)
|
||||
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
|
||||
option(onnxruntime_USE_NGRAPH "Build with nGraph support" OFF)
|
||||
option(onnxruntime_USE_NUPHAR "Build with Nuphar" OFF)
|
||||
|
|
@ -57,10 +57,7 @@ endif()
|
|||
if(onnxruntime_USE_OPENVINO)
|
||||
add_definitions(-DUSE_OPENVINO)
|
||||
endif()
|
||||
if(onnxruntime_USE_NNAPI)
|
||||
add_definitions(-DUSE_NNAPI)
|
||||
endif()
|
||||
if(onnxruntime_USE_NNAPI)
|
||||
if(onnxruntime_USE_NNAPI_DNNLIBRARY)
|
||||
add_definitions(-DUSE_NNAPI)
|
||||
endif()
|
||||
if(onnxruntime_USE_DNNL)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ project(onnxruntime C CXX)
|
|||
|
||||
option(onnxruntime_USE_CUDA "Build with CUDA support" OFF)
|
||||
option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
|
||||
option(onnxruntime_USE_NNAPI "Build with DNNLibrary for Android NNAPI support" OFF)
|
||||
option(onnxruntime_USE_NNAPI_DNNLIBRARY "Build with DNNLibrary for Android NNAPI support" OFF)
|
||||
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
|
||||
option(onnxruntime_USE_NGRAPH "Build with nGraph support" OFF)
|
||||
option(onnxruntime_USE_NUPHAR "Build with Nuphar" OFF)
|
||||
|
|
@ -23,7 +23,7 @@ endif()
|
|||
if(onnxruntime_USE_OPENVINO)
|
||||
add_definitions(-DUSE_OPENVINO=1)
|
||||
endif()
|
||||
if(onnxruntime_USE_NNAPI)
|
||||
if(onnxruntime_USE_NNAPI_DNNLIBRARY)
|
||||
add_definitions(-DUSE_NNAPI=1)
|
||||
endif()
|
||||
if(onnxruntime_USE_DNNL)
|
||||
|
|
@ -88,7 +88,7 @@ endif()
|
|||
add_custom_command(
|
||||
OUTPUT "${grpc_srcs}" "${grpc_hdrs}"
|
||||
COMMAND protoc
|
||||
ARGS
|
||||
ARGS
|
||||
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
--grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
--plugin=protoc-gen-grpc="${_gRPC_CPP_PLUGIN_EXECUTABLE}"
|
||||
|
|
@ -155,7 +155,7 @@ target_include_directories(onnxruntime_server_http_core_lib
|
|||
${ONNXRUNTIME_SERVER_ROOT}/http/core
|
||||
${ONNXRUNTIME_SERVER_ROOT}/core
|
||||
${Boost_INCLUDE_DIR}
|
||||
|
||||
|
||||
)
|
||||
add_dependencies(onnxruntime_server_http_core_lib Boost)
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ target_include_directories(onnxruntime_server_lib PRIVATE
|
|||
${ONNXRUNTIME_SERVER_ROOT}
|
||||
${ONNXRUNTIME_SERVER_ROOT}/http
|
||||
${ONNXRUNTIME_SERVER_ROOT}/logging
|
||||
${ONNXRUNTIME_SERVER_ROOT}/core
|
||||
${ONNXRUNTIME_SERVER_ROOT}/core
|
||||
PUBLIC
|
||||
${ONNXRUNTIME_SERVER_ROOT}/external/spdlog/include
|
||||
${ONNXRUNTIME_SERVER_ROOT}/http/core
|
||||
|
|
@ -208,10 +208,10 @@ target_include_directories(${SERVER_APP_NAME} PRIVATE
|
|||
target_link_libraries(${SERVER_APP_NAME} PRIVATE
|
||||
onnxruntime_server_http_core_lib
|
||||
onnxruntime_server_lib
|
||||
${grpc_reflection} #Note that this will break the tests if we try to link it to the lib so just link to the executable.
|
||||
${grpc_reflection} #Note that this will break the tests if we try to link it to the lib so just link to the executable.
|
||||
server_grpc_proto server_proto
|
||||
${Boost_LIBRARIES}
|
||||
onnxruntime_server_http_core_lib
|
||||
onnxruntime_server_http_core_lib
|
||||
${grpc_static_libs} protobuf::libprotobuf
|
||||
spdlog::spdlog
|
||||
onnxruntime gtest re2 ${CMAKE_DL_LIBS} Threads::Threads
|
||||
|
|
@ -237,15 +237,15 @@ file(GLOB onnxruntime_test_server_src
|
|||
set_source_files_properties("test/unit_tests/executor_test.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
add_executable(onnxruntime_server_tests ${onnxruntime_test_server_src})
|
||||
add_dependencies(onnxruntime_server_tests server_proto Boost)
|
||||
target_link_libraries(onnxruntime_server_tests PRIVATE onnxruntime_server_http_core_lib
|
||||
onnxruntime_server_lib
|
||||
${grpc_reflection} #Note that this will break the tests if we try to link it to the lib so just link to the executable.
|
||||
${grpc_reflection} #Note that this will break the tests if we try to link it to the lib so just link to the executable.
|
||||
server_grpc_proto server_proto
|
||||
${Boost_LIBRARIES}
|
||||
onnxruntime_server_http_core_lib
|
||||
onnxruntime_server_http_core_lib
|
||||
${grpc_static_libs} protobuf::libprotobuf
|
||||
spdlog::spdlog
|
||||
onnxruntime gtest re2 gtest ${CMAKE_DL_LIBS} Threads::Threads)
|
||||
|
|
@ -253,18 +253,18 @@ file(GLOB onnxruntime_test_server_src
|
|||
${ONNXRUNTIME_SERVER_ROOT}/http/core
|
||||
${ONNXRUNTIME_SERVER_ROOT} ${ONNXRUNTIME_SERVER_ROOT}/core)
|
||||
onnxruntime_protobuf_generate(
|
||||
APPEND_PATH IMPORT_DIRS ${ONNXRUNTIME_SERVER_ROOT}/protobuf
|
||||
APPEND_PATH IMPORT_DIRS ${ONNXRUNTIME_SERVER_ROOT}/protobuf
|
||||
PROTOS ${ONNXRUNTIME_SERVER_ROOT}/protobuf/predict.proto protobuf/onnx-ml.proto
|
||||
LANGUAGE python
|
||||
TARGET onnxruntime_server_tests
|
||||
OUT_VAR server_test_py)
|
||||
|
||||
|
||||
set(grpc_py "${CMAKE_CURRENT_BINARY_DIR}/prediction_service_pb2_grpc.py")
|
||||
|
||||
add_custom_command(
|
||||
TARGET onnxruntime_server_tests
|
||||
COMMAND protoc
|
||||
ARGS
|
||||
ARGS
|
||||
--grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
--plugin=protoc-gen-grpc=${_gRPC_PYTHON_PLUGIN_EXECUTABLE}
|
||||
-I ${grpc_proto_path}
|
||||
|
|
|
|||
|
|
@ -560,7 +560,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home,
|
|||
"ON" if args.use_openvino == "VAD-F_FP32" else "OFF"),
|
||||
"-Donnxruntime_USE_OPENVINO_BINARY=" + (
|
||||
"ON" if args.use_openvino else "OFF"),
|
||||
"-Donnxruntime_USE_NNAPI=" + ("ON" if args.use_dnnlibrary else "OFF"),
|
||||
"-Donnxruntime_USE_NNAPI_DNNLIBRARY=" + ("ON" if args.use_dnnlibrary else "OFF"),
|
||||
"-Donnxruntime_USE_RKNPU=" + ("ON" if args.use_rknpu else "OFF"),
|
||||
"-Donnxruntime_USE_OPENMP=" + (
|
||||
"ON" if args.use_openmp and not (
|
||||
|
|
@ -1545,6 +1545,8 @@ def main():
|
|||
if args.update:
|
||||
cmake_extra_args = []
|
||||
path_to_protoc_exe = args.path_to_protoc_exe
|
||||
if not args.skip_submodule_sync:
|
||||
update_submodules(source_dir)
|
||||
if is_windows():
|
||||
if args.cmake_generator == 'Ninja':
|
||||
if args.x86 or args.arm or args.arm64:
|
||||
|
|
@ -1617,8 +1619,6 @@ def main():
|
|||
install_python_deps()
|
||||
if args.enable_pybind and is_windows():
|
||||
install_python_deps(args.numpy_version)
|
||||
if not args.skip_submodule_sync:
|
||||
update_submodules(source_dir)
|
||||
if args.enable_onnx_tests:
|
||||
setup_test_data(build_dir, configs)
|
||||
generate_build_tree(
|
||||
|
|
|
|||
Loading…
Reference in a new issue