Skip to content

Commit 2ac2c45

Browse files
authored
Windows: Fixing random runtime error when import torch (#1043)
PyTorch has self logic of loading dll on Windows. The logic in torch-xpu-ops:bridge.cpp gets conflict against PyTorch logic. Signed-off-by: Feng Yuan <[email protected]>
1 parent ce19aa9 commit 2ac2c45

File tree

2 files changed

+2
-42
lines changed

2 files changed

+2
-42
lines changed

src/BuildOnWindows.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ set(SYCL_LINK_LIBRARIES_KEYWORD PRIVATE)
55

66
# Walk around cyclic dependence
77
# libtorch_xpu.so links to libtorch_xpu_ops.a
8-
# libtorch_xpu_ops.a dlopens libtorch_xpu_ops_aten.so (Break cycle)
8+
# Load libtorch_xpu_ops_aten.so explicitly by torch/__init__.py:_load_dll_libraries (Break cycle)
99
# libtorch_xpu_ops_aten.so links to libtorch_xpu_ops_sycl_unary_binary_kernels.so and libtorch_xpu_ops_sycl_kernels.so
1010
# libtorch_xpu_ops_sycl_unary_binary_kernels.so and libtorch_xpu_ops_sycl_kernels.so links to libtorch_xpu.so
1111
add_library(
1212
torch_xpu_ops
1313
STATIC
14-
${ATen_XPU_CPP_SRCS}
15-
"bridge.cpp")
14+
${ATen_XPU_CPP_SRCS})
1615
set(PATH_TO_TORCH_XPU_OPS_ATEN_LIB \"torch_xpu_ops_aten.dll\")
1716
target_compile_options(torch_xpu_ops PRIVATE -DPATH_TO_TORCH_XPU_OPS_ATEN_LIB=${PATH_TO_TORCH_XPU_OPS_ATEN_LIB})
1817

19-
2018
add_library(
2119
torch_xpu_ops_aten
2220
SHARED
@@ -29,9 +27,6 @@ target_link_libraries(torch_xpu_ops_aten PUBLIC torch_xpu)
2927
target_link_libraries(torch_xpu_ops_aten PUBLIC torch_cpu)
3028
target_link_libraries(torch_xpu_ops_aten PUBLIC c10)
3129

32-
33-
34-
3530
if(BUILD_SEPARATE_OPS)
3631
foreach(sycl_src ${ATen_XPU_SYCL_SRCS})
3732
get_filename_component(name ${sycl_src} NAME_WLE REALPATH)

src/bridge.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)