Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Build
shell: pwsh
run: |
python.exe "${{ github.workspace }}\tools\ci_build\build.py" --config RelWithDebInfo --build_dir "${{ github.workspace }}\build" --skip_submodule_sync --build_csharp --parallel --use_binskim_compliant_compile_flags --cmake_generator "Visual Studio 17 2022" --build_shared_lib --update --build --enable_generic_interface --use_vcpkg --use_vcpkg_ms_internal_asset_cache
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Remove-Item "${{ github.workspace }}\build\RelWithDebInfo" -Include "*.obj" -Recurse
env:
ALLOW_RELEASED_ONNX_OPSET_ONLY: '0'
- name: Build and test
shell: pwsh
run: |
python.exe "${{ github.workspace }}\tools\ci_build\build.py" --config RelWithDebInfo --build_dir "${{ github.workspace }}\build" --skip_submodule_sync --build_csharp --parallel --use_binskim_compliant_compile_flags --cmake_generator "Visual Studio 17 2022" --build_shared_lib --update --build --test --enable_generic_interface --use_vcpkg --use_vcpkg_ms_internal_asset_cache
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Remove-Item "${{ github.workspace }}\build\RelWithDebInfo" -Include "*.obj" -Recurse
env:
ALLOW_RELEASED_ONNX_OPSET_ONLY: '0'

- name: Validate C# native delegates
shell: cmd
Expand Down
26 changes: 7 additions & 19 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@ endif()
set(ONNXRUNTIME_PROVIDER_NAMES cpu)

set(ORT_PROVIDER_FLAGS)
set(ORT_EXTRA_INTERFACE_FLAGS)

if (onnxruntime_USE_CUDA)
enable_language(CUDA)
Expand Down Expand Up @@ -912,7 +911,7 @@ if (onnxruntime_USE_CUDA)
endif()

if (onnxruntime_USE_CUDA_INTERFACE AND (NOT onnxruntime_USE_CUDA))
list(APPEND ORT_EXTRA_INTERFACE_FLAGS -DUSE_CUDA=1)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_CUDA_PROVIDER_INTERFACE=1)
endif()

if (onnxruntime_USE_VITISAI)
Expand All @@ -921,7 +920,7 @@ if (onnxruntime_USE_VITISAI)
endif()

if (onnxruntime_USE_VITISAI_INTERFACE AND (NOT onnxruntime_USE_VITISAI))
list(APPEND ORT_EXTRA_INTERFACE_FLAGS -DUSE_VITISAI=1)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_VITISAI_PROVIDER_INTERFACE=1)
endif()

if (onnxruntime_USE_DNNL)
Expand All @@ -935,7 +934,7 @@ if (onnxruntime_USE_OPENVINO)
endif()

if (onnxruntime_USE_OPENVINO_INTERFACE AND (NOT onnxruntime_USE_OPENVINO))
list(APPEND ORT_EXTRA_INTERFACE_FLAGS -DUSE_OPENVINO=1)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_OPENVINO_PROVIDER_INTERFACE=1)
endif()

if (onnxruntime_USE_TENSORRT)
Expand All @@ -945,7 +944,7 @@ if (onnxruntime_USE_TENSORRT)
endif()

if (onnxruntime_USE_TENSORRT_INTERFACE AND (NOT onnxruntime_USE_TENSORRT))
list(APPEND ORT_INTERFACE_FLAGS -DUSE_TENSORRT=1)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_TENSORRT_PROVIDER_INTERFACE=1)
endif()

if (onnxruntime_USE_NV)
Expand All @@ -954,7 +953,7 @@ if (onnxruntime_USE_NV)
endif()

if (onnxruntime_USE_NV_INTERFACE AND (NOT onnxruntime_USE_NV))
list(APPEND ORT_INTERFACE_FLAGS -DUSE_NV=1)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_NV_PROVIDER_INTERFACE=1)
endif()

if (onnxruntime_USE_RKNPU)
Expand All @@ -978,7 +977,7 @@ if (onnxruntime_USE_QNN OR onnxruntime_USE_QNN_INTERFACE)
if(onnxruntime_USE_QNN)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_QNN=1)
else()
list(APPEND ORT_EXTRA_INTERFACE_FLAGS -DUSE_QNN=1)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_QNN_PROVIDER_INTERFACE=1)
endif()

list(APPEND ONNXRUNTIME_PROVIDER_NAMES qnn)
Expand Down Expand Up @@ -1242,12 +1241,6 @@ function(onnxruntime_set_compile_flags target_name)
target_compile_definitions(${target_name} PRIVATE ${ORT_FLAG})
endforeach()

if("${target_name}" STREQUAL "onnxruntime")
foreach(ORT_EXTRA_FLAG ${ORT_EXTRA_INTERFACE_FLAGS})
target_compile_definitions(${target_name} PRIVATE ${ORT_EXTRA_FLAG})
endforeach()
endif()

if (HAS_DEPRECATED_COPY)
#too many such errors in eigen
target_compile_options(${target_name} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options -Wno-deprecated-copy>" "$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-copy>")
Expand Down Expand Up @@ -1540,11 +1533,6 @@ if (onnxruntime_USE_OPENVINO)

endif()

if (onnxruntime_USE_OPENVINO_INTERFACE AND (NOT onnxruntime_USE_OPENVINO))
add_definitions(-DUSE_OPENVINO=1)
add_definitions(-DOPENVINO_CONFIG_NPU=1)
endif()

if (onnxruntime_USE_VITISAI)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}")
endif()
Expand Down Expand Up @@ -1745,7 +1733,7 @@ if(VERSION_MAJOR_PART STREQUAL "0" AND VERSION_MINOR_PART STREQUAL "0" AND VERSI
list(GET ORT_VERSION_STRING_LIST 0 VERSION_MAJOR_PART)
list(GET ORT_VERSION_STRING_LIST 1 VERSION_MINOR_PART)
list(GET ORT_VERSION_STRING_LIST 2 VERSION_BUILD_PART)
set(VERSION_STRING ORT_VERSION)
set(VERSION_STRING ${ORT_VERSION})
endif()


Expand Down
25 changes: 23 additions & 2 deletions cmake/onnxruntime_providers_cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,38 @@
if (onnxruntime_REDUCED_OPS_BUILD)
substitute_op_reduction_srcs(onnxruntime_providers_cuda_src)
endif()

if(onnxruntime_ENABLE_CUDA_EP_INTERNAL_TESTS)
# cuda_provider_interface.cc is removed from the object target: onnxruntime_providers_cuda_obj and
# added to the lib onnxruntime_providers_cuda separately.
# onnxruntime_providers_cuda_ut can share all the object files with onnxruntime_providers_cuda except cuda_provider_interface.cc.
set(cuda_provider_interface_src ${ONNXRUNTIME_ROOT}/core/providers/cuda/cuda_provider_interface.cc)
list(REMOVE_ITEM onnxruntime_providers_cuda_src ${cuda_provider_interface_src})
onnxruntime_add_object_library(onnxruntime_providers_cuda_obj ${onnxruntime_providers_cuda_src})
onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${cuda_provider_interface_src} $<TARGET_OBJECTS:onnxruntime_providers_cuda_obj>)

set(onnxruntime_providers_cuda_all_srcs ${cuda_provider_interface_src})
if(WIN32)
# Sets the DLL version info on Windows: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
list(APPEND onnxruntime_providers_cuda_all_srcs "${ONNXRUNTIME_ROOT}/core/providers/cuda/onnxruntime_providers_cuda.rc")
endif()

onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${onnxruntime_providers_cuda_all_srcs}
$<TARGET_OBJECTS:onnxruntime_providers_cuda_obj>)
else()
onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${onnxruntime_providers_cuda_src})
set(onnxruntime_providers_cuda_all_srcs ${onnxruntime_providers_cuda_src})
if(WIN32)
# Sets the DLL version info on Windows: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
list(APPEND onnxruntime_providers_cuda_all_srcs "${ONNXRUNTIME_ROOT}/core/providers/cuda/onnxruntime_providers_cuda.rc")
endif()

onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${onnxruntime_providers_cuda_all_srcs})
endif()

if(WIN32)
# FILE_NAME preprocessor definition is used in onnxruntime_providers_cuda.rc
target_compile_definitions(onnxruntime_providers_cuda PRIVATE FILE_NAME=\"onnxruntime_providers_cuda.dll\")
endif()

# config_cuda_provider_shared_module can be used to config onnxruntime_providers_cuda_obj, onnxruntime_providers_cuda & onnxruntime_providers_cuda_ut.
# This function guarantees that all 3 targets have the same configurations.
function(config_cuda_provider_shared_module target)
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime_providers_openvino.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
set_target_properties(onnxruntime_providers_openvino PROPERTIES FOLDER "ONNXRuntime")

target_compile_options(onnxruntime_providers_openvino PRIVATE
$<$<NOT:$<CONFIG:Release>>:-DNOT_RELEASE>
$<$<CONFIG:Release>:-DRELEASE>
)

if(NOT MSVC)
Expand Down
80 changes: 75 additions & 5 deletions cmake/onnxruntime_providers_qnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@
"${ONNXRUNTIME_ROOT}/core/providers/qnn/*.cc"
)

function(extract_qnn_sdk_version_from_yaml QNN_SDK_YAML_FILE QNN_VERSION_OUTPUT)
file(READ "${QNN_SDK_YAML_FILE}" QNN_SDK_YAML_CONTENT)
# Match a line of text like "version: 1.33.2"
string(REGEX MATCH "(^|\n|\r)version: ([0-9]+\\.[0-9]+\\.[0-9]+)" QNN_VERSION_MATCH "${QNN_SDK_YAML_CONTENT}")
if(QNN_VERSION_MATCH)
set(${QNN_VERSION_OUTPUT} "${CMAKE_MATCH_2}" PARENT_SCOPE)
message(STATUS "Extracted QNN SDK version ${CMAKE_MATCH_2} from ${QNN_SDK_YAML_FILE}")
else()
message(WARNING "Failed to extract QNN SDK version from ${QNN_SDK_YAML_FILE}")
endif()
endfunction()

if(NOT QNN_SDK_VERSION)
if(EXISTS "${onnxruntime_QNN_HOME}/sdk.yaml")
extract_qnn_sdk_version_from_yaml("${onnxruntime_QNN_HOME}/sdk.yaml" QNN_SDK_VERSION)
else()
message(WARNING "Cannot open sdk.yaml to extract QNN SDK version")
endif()
endif()
message(STATUS "QNN SDK version ${QNN_SDK_VERSION}")

if(onnxruntime_BUILD_QNN_EP_STATIC_LIB)
#
# Build QNN EP as a static library
Expand All @@ -23,7 +44,7 @@
onnxruntime_add_include_to_target(onnxruntime_providers_qnn onnxruntime_common onnxruntime_framework onnx
onnx_proto protobuf::libprotobuf-lite
flatbuffers::flatbuffers Boost::mp11
nlohmann_json::nlohmann_json)
nlohmann_json::nlohmann_json)
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")
Expand All @@ -36,6 +57,21 @@
if(NOT MSVC)
target_compile_options(onnxruntime_providers_qnn PRIVATE "-Wno-unknown-pragmas")
endif()

set(onnxruntime_providers_qnn_target onnxruntime_providers_qnn)

if (MSVC OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_custom_command(
TARGET ${onnxruntime_providers_qnn_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${QNN_LIB_FILES} $<TARGET_FILE_DIR:${onnxruntime_providers_qnn_target}>
)
endif()
if (EXISTS "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf")
add_custom_command(
TARGET ${onnxruntime_providers_qnn_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf" $<TARGET_FILE_DIR:${onnxruntime_providers_qnn_target}>
)
endif()
else()
#
# Build QNN EP as a shared library
Expand All @@ -46,20 +82,39 @@
"${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.cc"
)
set(onnxruntime_providers_qnn_srcs ${onnxruntime_providers_qnn_ep_srcs}
${onnxruntime_providers_qnn_shared_lib_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})

set(onnxruntime_providers_qnn_all_srcs ${onnxruntime_providers_qnn_srcs})
if(WIN32)
# Sets the DLL version info on Windows: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
list(APPEND onnxruntime_providers_qnn_all_srcs "${ONNXRUNTIME_ROOT}/core/providers/qnn/onnxruntime_providers_qnn.rc")
endif()

onnxruntime_add_shared_library_module(onnxruntime_providers_qnn ${onnxruntime_providers_qnn_all_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_qnn ${ONNXRUNTIME_PROVIDERS_SHARED} ${GSL_TARGET} onnx
onnxruntime_common Boost::mp11 safeint_interface
nlohmann_json::nlohmann_json)
onnxruntime_common Boost::mp11 safeint_interface
nlohmann_json::nlohmann_json)
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 preprocessor definitions used in onnxruntime_providers_qnn.rc
if(WIN32)
if(NOT QNN_SDK_VERSION)
set(QNN_DLL_FILE_DESCRIPTION "ONNX Runtime QNN Provider")
else()
set(QNN_DLL_FILE_DESCRIPTION "ONNX Runtime QNN Provider (QAIRT ${QNN_SDK_VERSION})")
endif()

target_compile_definitions(onnxruntime_providers_qnn PRIVATE FILE_DESC=\"${QNN_DLL_FILE_DESCRIPTION}\")
target_compile_definitions(onnxruntime_providers_qnn PRIVATE FILE_NAME=\"onnxruntime_providers_qnn.dll\")
endif()

# Set linker flags for function(s) exported by EP DLL
if(UNIX)
target_link_options(onnxruntime_providers_qnn PRIVATE
Expand Down Expand Up @@ -90,4 +145,19 @@
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

set(onnxruntime_providers_qnn_target onnxruntime_providers_qnn)

if (MSVC OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_custom_command(
TARGET ${onnxruntime_providers_qnn_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${QNN_LIB_FILES} $<TARGET_FILE_DIR:${onnxruntime_providers_qnn_target}>
)
endif()
if (EXISTS "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf")
add_custom_command(
TARGET ${onnxruntime_providers_qnn_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf" $<TARGET_FILE_DIR:${onnxruntime_providers_qnn_target}>
)
endif()
endif()
15 changes: 14 additions & 1 deletion cmake/onnxruntime_providers_tensorrt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,14 @@
)

source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_tensorrt_cc_srcs})
onnxruntime_add_shared_library_module(onnxruntime_providers_tensorrt ${onnxruntime_providers_tensorrt_cc_srcs})

set(onnxruntime_providers_tensorrt_all_srcs ${onnxruntime_providers_tensorrt_cc_srcs})
if(WIN32)
# Sets the DLL version info on Windows: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
list(APPEND onnxruntime_providers_tensorrt_all_srcs "${ONNXRUNTIME_ROOT}/core/providers/tensorrt/onnxruntime_providers_tensorrt.rc")
endif()

onnxruntime_add_shared_library_module(onnxruntime_providers_tensorrt ${onnxruntime_providers_tensorrt_all_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_tensorrt onnxruntime_common)
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE Eigen3::Eigen onnx flatbuffers::flatbuffers Boost::mp11 safeint_interface Eigen3::Eigen)
add_dependencies(onnxruntime_providers_tensorrt onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
Expand All @@ -183,6 +190,12 @@
set_target_properties(onnxruntime_providers_tensorrt PROPERTIES FOLDER "ONNXRuntime")
target_compile_definitions(onnxruntime_providers_tensorrt PRIVATE ONNXIFI_BUILD_LIBRARY=1)
target_compile_options(onnxruntime_providers_tensorrt PRIVATE ${DISABLED_WARNINGS_FOR_TRT})

if(WIN32)
# FILE_NAME preprocessor definition is used in onnxruntime_providers_tensorrt.rc
target_compile_definitions(onnxruntime_providers_tensorrt PRIVATE FILE_NAME=\"onnxruntime_providers_tensorrt.dll\")
endif()

if (WIN32)
target_compile_options(onnxruntime_providers_tensorrt INTERFACE /wd4456)
endif()
Expand Down
15 changes: 0 additions & 15 deletions cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1075,21 +1075,6 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
)
endif()

if (onnxruntime_USE_QNN)
if (MSVC OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_custom_command(
TARGET ${test_data_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${QNN_LIB_FILES} $<TARGET_FILE_DIR:${test_data_target}>
)
endif()
if (EXISTS "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf")
add_custom_command(
TARGET ${test_data_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf" $<TARGET_FILE_DIR:${test_data_target}>
)
endif()
endif()

if (onnxruntime_USE_DNNL)
if(onnxruntime_DNNL_GPU_RUNTIME STREQUAL "ocl" AND onnxruntime_DNNL_OPENCL_ROOT STREQUAL "")
message(FATAL_ERROR "--dnnl_opencl_root required")
Expand Down
Loading
Loading