Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python-onnxruntime: split C++ and Python libraries & some other changes
* Rename python-onnxruntime-cuda to onnxruntime-cuda - this split package actually does not contain Python libraries. * Move optdepends to the correct package * Drop flatbuffers fix after upstream adds the compatibility back [1] * Improve onednn patch - fallback to bundled onednn if the system one is missing & wrap other usage of `DNNL_DLL_PATH` * Add CUDA architectures introduced in CUDA 11.8. See [2] * Refresh patches for 1.13 [1] google/flatbuffers#7499 [2] archlinux/svntogit-community@54642de
- Loading branch information
Showing
3 changed files
with
76 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,57 @@ | ||
diff --git a/cmake/external/dnnl.cmake b/cmake/external/dnnl.cmake | ||
index 6a51a3d5d..a89635210 100644 | ||
index 5c42216..bc0a63f 100644 | ||
--- a/cmake/external/dnnl.cmake | ||
+++ b/cmake/external/dnnl.cmake | ||
@@ -26,6 +26,13 @@ elseif(onnxruntime_USE_DNNL AND onnxruntime_DNNL_GPU_RUNTIME STREQUAL "ocl" AND | ||
@@ -26,6 +26,17 @@ elseif(onnxruntime_USE_DNNL AND onnxruntime_DNNL_GPU_RUNTIME STREQUAL "ocl" AND | ||
endif() | ||
|
||
if (onnxruntime_USE_DNNL) | ||
+if (onnxruntime_PREFER_SYSTEM_LIB) | ||
+ # https://oneapi-src.github.io/oneDNN/dev_guide_transition_to_dnnl.html | ||
+ find_package(dnnl CONFIG REQUIRED) | ||
+ find_package(dnnl CONFIG) | ||
+endif () | ||
+if (TARGET DNNL::dnnl) | ||
+ message("Use DNNL from preinstalled system lib") | ||
+ add_library(project_dnnl INTERFACE) | ||
+ add_library(dnnl INTERFACE) | ||
+ target_link_libraries(dnnl INTERFACE DNNL::dnnl) | ||
+else () | ||
+ message("Use DNNL from submodule") | ||
set(DNNL_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/dnnl/src/dnnl/src) | ||
set(DNNL_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/dnnl/install) | ||
set(DNNL_LIB_DIR ${DNNL_INSTALL}/${CMAKE_INSTALL_LIBDIR}) | ||
@@ -55,3 +62,4 @@ if (onnxruntime_USE_DNNL) | ||
@@ -55,3 +66,4 @@ if (onnxruntime_USE_DNNL) | ||
) | ||
link_directories(${DNNL_LIB_DIR}) | ||
endif() | ||
+endif() | ||
diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake | ||
index b23d731..13ef7c3 100644 | ||
--- a/cmake/onnxruntime_python.cmake | ||
+++ b/cmake/onnxruntime_python.cmake | ||
@@ -752,7 +752,7 @@ if (onnxruntime_ENABLE_TRAINING) | ||
endif() | ||
endif() | ||
|
||
-if (onnxruntime_USE_DNNL) | ||
+if (onnxruntime_USE_DNNL AND NOT TARGET DNNL::dnnl) | ||
add_custom_command( | ||
TARGET onnxruntime_pybind11_state POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy | ||
diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake | ||
index 6bdb2d03c..514faa375 100644 | ||
index c5e1dfe..a9cb311 100644 | ||
--- a/cmake/onnxruntime_unittests.cmake | ||
+++ b/cmake/onnxruntime_unittests.cmake | ||
@@ -744,10 +744,12 @@ add_custom_command( | ||
if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP) | ||
@@ -836,10 +836,12 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP) | ||
endif() | ||
if (onnxruntime_USE_DNNL) | ||
list(APPEND onnx_test_libs dnnl) | ||
+ if (NOT onnxruntime_PREFER_SYSTEM_LIB) | ||
+ if (NOT TARGET DNNL::dnnl) | ||
add_custom_command( | ||
TARGET ${test_data_target} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy ${DNNL_DLL_PATH} $<TARGET_FILE_DIR:${test_data_target}> | ||
) | ||
+ endif() | ||
endif() | ||
if(WIN32) | ||
if (onnxruntime_USE_TVM) | ||
if (onnxruntime_USE_NUPHAR_TVM) |