mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
### Description <!-- Describe your changes. --> If the EP handles QDQ node units, we need to make sure we do not split those into different partitions. Update the partitioning utils to be QDQ aware. If there are node units we process the logical nodes they represent instead of individual nodes. This ensure we process all nodes in a QDQ node unit at the same time so that they are always in the same partition. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Fix one of the issues in #19590 --------- Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
82 lines
4.4 KiB
CMake
82 lines
4.4 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 separate 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"
|
|
)
|
|
|
|
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()
|