Unverified Commit 799c091e authored by nv-dlasalle's avatar nv-dlasalle Committed by GitHub
Browse files

[bugfix] Only link the pytorch tensordispatcher against libtorch (#3225)

* Only link tensordispatcher against pytorch

* Only modify libraries when not using MSVC
parent bcf92f6c
......@@ -39,8 +39,10 @@ bool TensorDispatcher::Load(const char *path) {
#else // !WIN32
handle_ = dlopen(path, RTLD_LAZY);
if (!handle_)
if (!handle_) {
LOG(WARNING) << "TensorDispatcher: dlopen failed: " << dlerror();
return false;
}
for (int i = 0; i < num_entries_; ++i) {
entrypoints_[i] = dlsym(handle_, names_[i]);
......
......@@ -27,8 +27,15 @@ set(TORCH_TARGET_NAME "tensoradapter_pytorch_${TORCH_VER}")
file(GLOB TA_TORCH_SRC *.cpp)
add_library(${TORCH_TARGET_NAME} SHARED "${TA_TORCH_SRC}")
if (MSVC)
# Linking on windows requires all libraries
set(TENSORADAPTER_TORCH_LIBS ${TORCH_LIBRARIES})
else()
set(TENSORADAPTER_TORCH_LIBS ${TORCH_LIBRARY})
endif(MSVC)
message(STATUS "tensoradapter found PyTorch includes: ${TORCH_INCLUDE_DIRS}")
message(STATUS "tensoradapter found PyTorch lib: ${TORCH_LIBRARIES}")
message(STATUS "tensoradapter found PyTorch lib: ${TENSORADAPTER_TORCH_LIBS}")
target_include_directories(
${TORCH_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../include")
......@@ -36,6 +43,6 @@ target_include_directories(
${TORCH_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/dlpack/include")
target_include_directories(
${TORCH_TARGET_NAME} PRIVATE "${TORCH_INCLUDE_DIRS}")
target_link_libraries(${TORCH_TARGET_NAME} PRIVATE "${TORCH_LIBRARIES}")
target_link_libraries(${TORCH_TARGET_NAME} PRIVATE "${TENSORADAPTER_TORCH_LIBS}")
set_property(TARGET ${TORCH_TARGET_NAME} PROPERTY CXX_STANDARD 14)
message(STATUS "Configured target ${TORCH_TARGET_NAME}")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment