Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into snnn/vcpkg2
Browse files Browse the repository at this point in the history
  • Loading branch information
snnn committed Jan 22, 2025
2 parents 3663a53 + 3b4c7df commit b5d4139
Show file tree
Hide file tree
Showing 100 changed files with 2,297 additions and 692 deletions.
1 change: 1 addition & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
option(onnxruntime_USE_COREML "Build with CoreML support" OFF)
option(onnxruntime_USE_NNAPI_BUILTIN "Build with builtin NNAPI lib for Android NNAPI support" OFF)
option(onnxruntime_USE_QNN "Build with QNN support" OFF)
option(onnxruntime_BUILD_QNN_EP_STATIC_LIB "Build with QNN EP as a static library" OFF)
option(onnxruntime_USE_SNPE "Build with SNPE support" OFF)
option(onnxruntime_USE_RKNPU "Build with RKNPU support" OFF)
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
Expand Down
19 changes: 13 additions & 6 deletions cmake/onnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_BUILD_JAVA)
endforeach()
endif()

# This list is a reversed topological ordering of library dependencies.
# Earlier entries may depend on later ones. Later ones should not depend on earlier ones.
set(onnxruntime_INTERNAL_LIBRARIES
onnxruntime_session
${onnxruntime_libs}
set(onnxruntime_INTERNAL_PROVIDER_LIBRARIES
${PROVIDERS_ACL}
${PROVIDERS_ARMNN}
${PROVIDERS_COREML}
${PROVIDERS_DML}
${PROVIDERS_NNAPI}
${PROVIDERS_QNN}
${PROVIDERS_SNPE}
${PROVIDERS_RKNPU}
${PROVIDERS_VSINPU}
Expand All @@ -218,6 +213,18 @@ set(onnxruntime_INTERNAL_LIBRARIES
${PROVIDERS_WEBNN}
${PROVIDERS_AZURE}
${PROVIDERS_INTERNAL_TESTING}
)

if (onnxruntime_BUILD_QNN_EP_STATIC_LIB)
list(APPEND onnxruntime_INTERNAL_PROVIDER_LIBRARIES onnxruntime_providers_qnn)
endif()

# This list is a reversed topological ordering of library dependencies.
# Earlier entries may depend on later ones. Later ones should not depend on earlier ones.
set(onnxruntime_INTERNAL_LIBRARIES
onnxruntime_session
${onnxruntime_libs}
${onnxruntime_INTERNAL_PROVIDER_LIBRARIES}
${onnxruntime_winml}
onnxruntime_optimizer
onnxruntime_providers
Expand Down
10 changes: 8 additions & 2 deletions cmake/onnxruntime_java.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ if (WIN32)
if(NOT onnxruntime_ENABLE_STATIC_ANALYSIS)
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime> ${JAVA_PACKAGE_LIB_DIR}/$<TARGET_FILE_NAME:onnxruntime>)
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime4j_jni> ${JAVA_PACKAGE_JNI_DIR}/$<TARGET_FILE_NAME:onnxruntime4j_jni>)
if (onnxruntime_USE_CUDA OR onnxruntime_USE_DNNL OR onnxruntime_USE_OPENVINO OR onnxruntime_USE_TENSORRT)
if (onnxruntime_USE_CUDA OR onnxruntime_USE_DNNL OR onnxruntime_USE_OPENVINO OR onnxruntime_USE_TENSORRT OR (onnxruntime_USE_QNN AND NOT onnxruntime_BUILD_QNN_EP_STATIC_LIB))
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime_providers_shared> ${JAVA_PACKAGE_LIB_DIR}/$<TARGET_FILE_NAME:onnxruntime_providers_shared>)
endif()
if (onnxruntime_USE_CUDA)
Expand All @@ -163,11 +163,14 @@ if (WIN32)
if (onnxruntime_USE_TENSORRT)
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime_providers_tensorrt> ${JAVA_PACKAGE_LIB_DIR}/$<TARGET_FILE_NAME:onnxruntime_providers_tensorrt>)
endif()
if (onnxruntime_USE_QNN AND NOT onnxruntime_BUILD_QNN_EP_STATIC_LIB)
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime_providers_qnn> ${JAVA_PACKAGE_LIB_DIR}/$<TARGET_FILE_NAME:onnxruntime_providers_qnn>)
endif()
endif()
else()
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime> ${JAVA_PACKAGE_LIB_DIR}/$<TARGET_LINKER_FILE_NAME:onnxruntime>)
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime4j_jni> ${JAVA_PACKAGE_JNI_DIR}/$<TARGET_LINKER_FILE_NAME:onnxruntime4j_jni>)
if (onnxruntime_USE_CUDA OR onnxruntime_USE_DNNL OR onnxruntime_USE_OPENVINO OR onnxruntime_USE_TENSORRT)
if (onnxruntime_USE_CUDA OR onnxruntime_USE_DNNL OR onnxruntime_USE_OPENVINO OR onnxruntime_USE_TENSORRT OR (onnxruntime_USE_QNN AND NOT onnxruntime_BUILD_QNN_EP_STATIC_LIB))
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime_providers_shared> ${JAVA_PACKAGE_LIB_DIR}/$<TARGET_LINKER_FILE_NAME:onnxruntime_providers_shared>)
endif()
if (onnxruntime_USE_CUDA)
Expand All @@ -182,6 +185,9 @@ else()
if (onnxruntime_USE_TENSORRT)
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime_providers_tensorrt> ${JAVA_PACKAGE_LIB_DIR}/$<TARGET_LINKER_FILE_NAME:onnxruntime_providers_tensorrt>)
endif()
if (onnxruntime_USE_QNN AND NOT onnxruntime_BUILD_QNN_EP_STATIC_LIB)
add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime_providers_qnn> ${JAVA_PACKAGE_LIB_DIR}/$<TARGET_LINKER_FILE_NAME:onnxruntime_providers_qnn>)
endif()
endif()

# run the build process (this copies the results back into CMAKE_CURRENT_BINARY_DIR)
Expand Down
3 changes: 0 additions & 3 deletions cmake/onnxruntime_providers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ endif()
if(onnxruntime_USE_JSEP)
set(PROVIDERS_JS onnxruntime_providers_js)
endif()
if(onnxruntime_USE_QNN)
set(PROVIDERS_QNN onnxruntime_providers_qnn)
endif()
if(onnxruntime_USE_RKNPU)
set(PROVIDERS_RKNPU onnxruntime_providers_rknpu)
endif()
Expand Down
4 changes: 3 additions & 1 deletion cmake/onnxruntime_providers_cpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -exported_symbols_list ${ONNXRUNTIME_ROOT}/core/providers/shared/exported_symbols.lst")
elseif(UNIX)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/core/providers/shared/version_script.lds -Xlinker --gc-sections")
target_link_options(onnxruntime_providers_shared PRIVATE
"LINKER:--version-script=${ONNXRUNTIME_ROOT}/core/providers/shared/version_script.lds"
"LINKER:--gc-sections")
endif()
elseif(WIN32)
set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${ONNXRUNTIME_ROOT}/core/providers/shared/symbols.def")
Expand Down
110 changes: 79 additions & 31 deletions cmake/onnxruntime_providers_qnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,89 @@

add_compile_definitions(USE_QNN=1)

# These are shared utils,
# TODO, move to a separate lib when used by EPs other than QNN, NNAPI and CoreML
file(GLOB onnxruntime_providers_shared_utils_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.cc"
)
if(onnxruntime_BUILD_QNN_EP_STATIC_LIB)
add_compile_definitions(BUILD_QNN_EP_STATIC_LIB=1)
endif()

file(GLOB_RECURSE
onnxruntime_providers_qnn_ep_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/qnn/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/qnn/*.cc"
onnxruntime_providers_qnn_ep_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/qnn/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/qnn/*.cc"
)

file(GLOB_RECURSE
onnxruntime_providers_qnn_builder_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/qnn/builder/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/qnn/builder/*.cc"
)
if(onnxruntime_BUILD_QNN_EP_STATIC_LIB)
#
# Build QNN EP as a static library
#
set(onnxruntime_providers_qnn_srcs ${onnxruntime_providers_qnn_ep_srcs})
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_qnn_srcs})
onnxruntime_add_static_library(onnxruntime_providers_qnn ${onnxruntime_providers_qnn_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_qnn onnxruntime_common onnxruntime_framework onnx
onnx_proto protobuf::libprotobuf-lite
flatbuffers::flatbuffers Boost::mp11)
add_dependencies(onnxruntime_providers_qnn onnx ${onnxruntime_EXTERNAL_DEPENDENCIES})
set_target_properties(onnxruntime_providers_qnn PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(onnxruntime_providers_qnn PROPERTIES FOLDER "ONNXRuntime")
target_include_directories(onnxruntime_providers_qnn PRIVATE ${ONNXRUNTIME_ROOT}
${onnxruntime_QNN_HOME}/include/QNN
${onnxruntime_QNN_HOME}/include)
set_target_properties(onnxruntime_providers_qnn PROPERTIES LINKER_LANGUAGE CXX)

set(onnxruntime_providers_qnn_cc_srcs
${onnxruntime_providers_shared_utils_cc_srcs}
${onnxruntime_providers_qnn_ep_cc_srcs}
${onnxruntime_providers_qnn_builder_cc_srcs}
)
# ignore the warning unknown-pragmas on "pragma region"
if(NOT MSVC)
target_compile_options(onnxruntime_providers_qnn PRIVATE "-Wno-unknown-pragmas")
endif()
else()
#
# Build QNN EP as a shared library
#
file(GLOB_RECURSE
onnxruntime_providers_qnn_shared_lib_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.cc"
)
set(onnxruntime_providers_qnn_srcs ${onnxruntime_providers_qnn_ep_srcs}
${onnxruntime_providers_qnn_shared_lib_srcs})

source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_qnn_srcs})
onnxruntime_add_shared_library_module(onnxruntime_providers_qnn ${onnxruntime_providers_qnn_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_qnn ${ONNXRUNTIME_PROVIDERS_SHARED} ${GSL_TARGET} onnx
onnxruntime_common Boost::mp11 safeint_interface)
target_link_libraries(onnxruntime_providers_qnn PRIVATE ${ONNXRUNTIME_PROVIDERS_SHARED} ${ABSEIL_LIBS} ${CMAKE_DL_LIBS})
add_dependencies(onnxruntime_providers_qnn onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnxruntime_providers_qnn PRIVATE ${ONNXRUNTIME_ROOT}
${CMAKE_CURRENT_BINARY_DIR}
${onnxruntime_QNN_HOME}/include/QNN
${onnxruntime_QNN_HOME}/include)

# Set linker flags for function(s) exported by EP DLL
if(UNIX)
target_link_options(onnxruntime_providers_qnn PRIVATE
"LINKER:--version-script=${ONNXRUNTIME_ROOT}/core/providers/qnn/version_script.lds"
"LINKER:--gc-sections"
"LINKER:-rpath=\$ORIGIN"
)
elseif(WIN32)
set_property(TARGET onnxruntime_providers_qnn APPEND_STRING PROPERTY LINK_FLAGS
"-DEF:${ONNXRUNTIME_ROOT}/core/providers/qnn/symbols.def")
else()
message(FATAL_ERROR "onnxruntime_providers_qnn unknown platform, need to specify shared library exports for it")
endif()

# Set compile options
if(MSVC)
target_compile_options(onnxruntime_providers_qnn PUBLIC /wd4099 /wd4005)
else()
# ignore the warning unknown-pragmas on "pragma region"
target_compile_options(onnxruntime_providers_qnn PRIVATE "-Wno-unknown-pragmas")
endif()

set_target_properties(onnxruntime_providers_qnn PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(onnxruntime_providers_qnn PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(onnxruntime_providers_qnn PROPERTIES FOLDER "ONNXRuntime")

source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_qnn_cc_srcs})
onnxruntime_add_static_library(onnxruntime_providers_qnn ${onnxruntime_providers_qnn_cc_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_qnn onnxruntime_common onnxruntime_framework onnx onnx_proto protobuf::libprotobuf-lite flatbuffers::flatbuffers Boost::mp11)
target_link_libraries(onnxruntime_providers_qnn)
add_dependencies(onnxruntime_providers_qnn onnx ${onnxruntime_EXTERNAL_DEPENDENCIES})
set_target_properties(onnxruntime_providers_qnn PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(onnxruntime_providers_qnn PROPERTIES FOLDER "ONNXRuntime")
target_include_directories(onnxruntime_providers_qnn PRIVATE ${ONNXRUNTIME_ROOT} ${onnxruntime_QNN_HOME}/include/QNN ${onnxruntime_QNN_HOME}/include)
set_target_properties(onnxruntime_providers_qnn PROPERTIES LINKER_LANGUAGE CXX)
# ignore the warning unknown-pragmas on "pragma region"
if(NOT MSVC)
target_compile_options(onnxruntime_providers_qnn PRIVATE "-Wno-unknown-pragmas")
install(TARGETS onnxruntime_providers_qnn
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
25 changes: 21 additions & 4 deletions cmake/onnxruntime_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ if (onnxruntime_ENABLE_LAZY_TENSOR)
endif()
endif()

target_link_libraries(onnxruntime_pybind11_state PRIVATE
onnxruntime_session
${onnxruntime_libs}
set(onnxruntime_pybind11_state_static_providers
${PROVIDERS_NNAPI}
${PROVIDERS_VSINPU}
${PROVIDERS_XNNPACK}
Expand All @@ -183,7 +181,16 @@ target_link_libraries(onnxruntime_pybind11_state PRIVATE
${PROVIDERS_XNNPACK}
${PROVIDERS_WEBGPU}
${PROVIDERS_AZURE}
${PROVIDERS_QNN}
)

if(onnxruntime_BUILD_QNN_EP_STATIC_LIB)
list(APPEND onnxruntime_pybind11_state_static_providers PRIVATE onnxruntime_providers_qnn)
endif()

target_link_libraries(onnxruntime_pybind11_state PRIVATE
onnxruntime_session
${onnxruntime_libs}
${onnxruntime_pybind11_state_static_providers}
onnxruntime_optimizer
onnxruntime_providers
onnxruntime_util
Expand Down Expand Up @@ -1000,6 +1007,16 @@ if (onnxruntime_USE_COREML)
endif()

if (onnxruntime_USE_QNN)
if(NOT onnxruntime_BUILD_QNN_EP_STATIC_LIB)
add_custom_command(
TARGET onnxruntime_pybind11_state POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:onnxruntime_providers_qnn>
$<TARGET_FILE:onnxruntime_providers_shared>
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/capi/
)
endif()

add_custom_command(
TARGET onnxruntime_pybind11_state POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
Expand Down
24 changes: 17 additions & 7 deletions cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -619,16 +619,13 @@ if(onnxruntime_USE_ARMNN)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_armnn)
endif()

set(ONNXRUNTIME_TEST_LIBS
onnxruntime_session
${ONNXRUNTIME_INTEROP_TEST_LIBS}
${onnxruntime_libs}
# CUDA, ROCM, TENSORRT, MIGRAPHX, DNNL, and OpenVINO are dynamically loaded at runtime
set(ONNXRUNTIME_TEST_STATIC_PROVIDER_LIBS
# CUDA, ROCM, TENSORRT, MIGRAPHX, DNNL, and OpenVINO are dynamically loaded at runtime.
# QNN EP can be built as either a dynamic and static libs.
${PROVIDERS_NNAPI}
${PROVIDERS_VSINPU}
${PROVIDERS_JS}
${PROVIDERS_WEBGPU}
${PROVIDERS_QNN}
${PROVIDERS_SNPE}
${PROVIDERS_RKNPU}
${PROVIDERS_DML}
Expand All @@ -637,6 +634,17 @@ set(ONNXRUNTIME_TEST_LIBS
${PROVIDERS_COREML}
${PROVIDERS_XNNPACK}
${PROVIDERS_AZURE}
)

if (onnxruntime_BUILD_QNN_EP_STATIC_LIB)
list(APPEND ONNXRUNTIME_TEST_STATIC_PROVIDER_LIBS onnxruntime_providers_qnn)
endif()

set(ONNXRUNTIME_TEST_LIBS
onnxruntime_session
${ONNXRUNTIME_INTEROP_TEST_LIBS}
${onnxruntime_libs}
${ONNXRUNTIME_TEST_STATIC_PROVIDER_LIBS}
onnxruntime_optimizer
onnxruntime_providers
onnxruntime_util
Expand Down Expand Up @@ -700,7 +708,9 @@ if(onnxruntime_USE_QNN AND NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_RED
list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/qnn/*)
list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_qnn)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_qnn)
list(APPEND onnxruntime_test_providers_libs onnxruntime_providers_qnn)
if(NOT onnxruntime_BUILD_QNN_EP_STATIC_LIB)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_shared)
endif()
endif()

if(onnxruntime_USE_SNPE)
Expand Down
22 changes: 19 additions & 3 deletions java/src/main/java/ai/onnxruntime/OnnxRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ final class OnnxRuntime {
/** The short name of the ONNX runtime TensorRT provider library */
static final String ONNXRUNTIME_LIBRARY_TENSORRT_NAME = "onnxruntime_providers_tensorrt";

/** The short name of the ONNX runtime QNN provider library */
static final String ONNXRUNTIME_LIBRARY_QNN_NAME = "onnxruntime_providers_qnn";

/** The OS & CPU architecture string */
private static final String OS_ARCH_STR = initOsArch();

Expand Down Expand Up @@ -159,8 +162,11 @@ static synchronized void init() throws IOException {
// the ONNX Runtime native library will load it
extractProviderLibrary(ONNXRUNTIME_LIBRARY_SHARED_NAME);

load(ONNXRUNTIME_LIBRARY_NAME);
if (!isAndroid()) {
load(ONNXRUNTIME_LIBRARY_NAME);
}
load(ONNXRUNTIME_JNI_LIBRARY_NAME);

ortApiHandle = initialiseAPIBase(ORT_API_VERSION_14);
if (ortApiHandle == 0L) {
throw new IllegalStateException(
Expand Down Expand Up @@ -252,6 +258,16 @@ static boolean extractTensorRT() {
return extractProviderLibrary(ONNXRUNTIME_LIBRARY_TENSORRT_NAME);
}

/**
* Extracts the QNN provider library from the classpath resources if present, or checks to see if
* the QNN provider library is in the directory specified by {@link #ONNXRUNTIME_NATIVE_PATH}.
*
* @return True if the QNN provider library is ready for loading, false otherwise.
*/
static boolean extractQNN() {
return extractProviderLibrary(ONNXRUNTIME_LIBRARY_QNN_NAME);
}

/**
* Extracts a shared provider library from the classpath resources if present, or checks to see if
* that library is in the directory specified by {@link #ONNXRUNTIME_NATIVE_PATH}.
Expand All @@ -260,7 +276,7 @@ static boolean extractTensorRT() {
* @return True if the library is ready for loading by ORT's native code, false otherwise.
*/
static synchronized boolean extractProviderLibrary(String libraryName) {
// Android does not need to extract library and it has no shared provider library
// Android does not need to extract provider libraries.
if (isAndroid()) {
return false;
}
Expand Down Expand Up @@ -312,7 +328,7 @@ static boolean isAndroid() {
private static void load(String library) throws IOException {
// On Android, we simply use System.loadLibrary
if (isAndroid()) {
System.loadLibrary("onnxruntime4j_jni");
System.loadLibrary(library);
return;
}

Expand Down
4 changes: 4 additions & 0 deletions java/src/main/java/ai/onnxruntime/OrtSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,10 @@ public void addXnnpack(Map<String, String> providerOptions) throws OrtException
*/
public void addQnn(Map<String, String> providerOptions) throws OrtException {
String qnnProviderName = "QNN";

// QNN can either be built as a shared or static library. extractQNN() will extract the
// (lib)onnxruntime_providers_qnn(.so/.dll) from classpath resources if present.
OnnxRuntime.extractQNN();
addExecutionProvider(qnnProviderName, providerOptions);
}

Expand Down
Loading

0 comments on commit b5d4139

Please sign in to comment.