mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-16 21:00:14 +00:00
### Description Split onnxruntime_providers.cmake to multiple files, for easier editing. No other change was made in this PR.
84 lines
No EOL
4.5 KiB
CMake
84 lines
No EOL
4.5 KiB
CMake
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
|
|
if (onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD)
|
|
message(FATAL_ERROR "NNAPI can not be used in a basic minimal build. Please build with '--minimal_build extended'")
|
|
endif()
|
|
|
|
add_compile_definitions(USE_NNAPI=1)
|
|
|
|
# This is the minimum Android API Level required by ORT NNAPI EP to run
|
|
# ORT running on any host system with Android API level less than this will fall back to CPU EP
|
|
if(onnxruntime_NNAPI_MIN_API)
|
|
add_compile_definitions(ORT_NNAPI_MIN_API_LEVEL=${onnxruntime_NNAPI_MIN_API})
|
|
endif()
|
|
|
|
# This is the maximum Android API level supported in the ort model conversion for NNAPI EP
|
|
# Note: This is only for running NNAPI for ort format model conversion on non-Android system since we cannot
|
|
# get the actually Android system version.
|
|
if(onnxruntime_NNAPI_HOST_API)
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
message(FATAL_ERROR "onnxruntime_NNAPI_HOST_API should only be set for non-Android target")
|
|
endif()
|
|
add_compile_definitions(ORT_NNAPI_MAX_SUPPORTED_API_LEVEL=${onnxruntime_NNAPI_HOST_API})
|
|
endif()
|
|
|
|
set(onnxruntime_provider_nnapi_cc_src_patterns
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/*.cc"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/*.cc"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/builders/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/builders/*.cc"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/builders/impl/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/builders/impl/*.cc"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/nnapi_lib/NeuralNetworksTypes.h"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/nnapi_lib/NeuralNetworksWrapper.h"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/nnapi_lib/NeuralNetworksWrapper.cc"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/nnapi_lib/nnapi_implementation.h"
|
|
)
|
|
|
|
# On Android, use the actual NNAPI implementation.
|
|
# Otherwise, use a stub implementation to support some unit testing.
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
list(APPEND onnxruntime_provider_nnapi_cc_src_patterns
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/nnapi_lib/nnapi_implementation.cc")
|
|
else()
|
|
list(APPEND onnxruntime_provider_nnapi_cc_src_patterns
|
|
"${ONNXRUNTIME_ROOT}/core/providers/nnapi/nnapi_builtin/nnapi_lib/nnapi_implementation_stub.cc")
|
|
endif()
|
|
|
|
# These are shared utils,
|
|
# TODO, move this to a separated lib when used by EPs other than NNAPI and CoreML
|
|
list(APPEND onnxruntime_provider_nnapi_cc_src_patterns
|
|
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.h"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.cc"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.h"
|
|
"${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.cc"
|
|
)
|
|
|
|
file(GLOB onnxruntime_providers_nnapi_cc_srcs CONFIGURE_DEPENDS ${onnxruntime_provider_nnapi_cc_src_patterns})
|
|
|
|
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_nnapi_cc_srcs})
|
|
onnxruntime_add_static_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_LIB} flatbuffers::flatbuffers Boost::mp11 safeint_interface
|
|
)
|
|
target_link_libraries(onnxruntime_providers_nnapi)
|
|
add_dependencies(onnxruntime_providers_nnapi onnx ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
|
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)
|
|
# ignore the warning unknown-pragmas on "pragma region"
|
|
if(NOT MSVC)
|
|
target_compile_options(onnxruntime_providers_nnapi PRIVATE "-Wno-unknown-pragmas")
|
|
endif()
|
|
|
|
if (NOT onnxruntime_BUILD_SHARED_LIB)
|
|
install(TARGETS onnxruntime_providers_nnapi
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
endif() |