mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-16 21:00:14 +00:00
Re-apply fix for mkl issue for eager mode (#12881)
* reapply fix for mkl issue for eager mode * add comment, update link libs
This commit is contained in:
parent
ff52d6a6bf
commit
6ebb7b91eb
1 changed files with 11 additions and 1 deletions
|
|
@ -154,9 +154,19 @@ if (onnxruntime_ENABLE_EAGER_MODE OR onnxruntime_ENABLE_LAZY_TENSOR)
|
|||
"${REPO_ROOT}/cmake/external/protobuf/src"
|
||||
${TORCH_INCLUDE_DIRS})
|
||||
|
||||
if (onnxruntime_ENABLE_EAGER_MODE)
|
||||
# For eager mode, torch build has a mkl dependency from torch's cmake config,
|
||||
# Linking to torch libraries to avoid this unnecessary mkl dependency.
|
||||
target_include_directories(onnxruntime_pybind11_state PRIVATE "${TORCH_INSTALL_PREFIX}/include" "${TORCH_INSTALL_PREFIX}/include/torch/csrc/api/include")
|
||||
find_library(LIBTORCH_LIBRARY torch PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||
find_library(LIBTORCH_CPU_LIBRARY torch_cpu PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||
find_library(LIBC10_LIBRARY c10 PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||
target_link_libraries(onnxruntime_pybind11_state PRIVATE ${LIBTORCH_LIBRARY} ${LIBTORCH_CPU_LIBRARY} ${LIBC10_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Explicitly link torch_python to workaround https://github.com/pytorch/pytorch/issues/38122#issuecomment-694203281
|
||||
find_library(TORCH_PYTHON_LIBRARY torch_python PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||
target_link_libraries(onnxruntime_pybind11_state PRIVATE ${TORCH_PYTHON_LIBRARY} ${TORCH_LIBRARIES})
|
||||
target_link_libraries(onnxruntime_pybind11_state PRIVATE ${TORCH_PYTHON_LIBRARY})
|
||||
if (onnxruntime_ENABLE_EAGER_MODE)
|
||||
target_link_libraries(onnxruntime_pybind11_state PRIVATE onnxruntime_eager)
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Reference in a new issue