mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 00:20:18 +01:00
export AOTI_TORCH_EXPORT on Windows. (#140030)
Fixes #139954 reproduce UT: ```cmd pytest test/inductor/test_torchinductor_codegen_dynamic_shapes.py -k test_device_assert_dynamic_shapes_cpu ``` Issue: <img width="856" alt="image" src="https://github.com/user-attachments/assets/5fc501a9-54e5-45ac-9fb3-509ec11a7abe"> After fixing:  Reland: 1. Declare export on Windows explicitly. 2. Support cpu, cuda and xpu devices. Pull Request resolved: https://github.com/pytorch/pytorch/pull/140030 Approved by: https://github.com/jgong5, https://github.com/desertfire
This commit is contained in:
parent
ad2cc96218
commit
38e0f72274
|
|
@ -779,6 +779,7 @@ endif()
|
|||
|
||||
if(NOT BUILD_LIBTORCHLESS)
|
||||
add_library(torch_cpu ${Caffe2_CPU_SRCS})
|
||||
target_compile_definitions(torch_cpu PRIVATE -DEXPORT_AOTI_FUNCTIONS)
|
||||
if(HAVE_SOVERSION)
|
||||
set_target_properties(torch_cpu PROPERTIES
|
||||
VERSION ${TORCH_VERSION} SOVERSION ${TORCH_SOVERSION})
|
||||
|
|
@ -963,6 +964,7 @@ elseif(USE_CUDA)
|
|||
set(CUDA_LINK_LIBRARIES_KEYWORD)
|
||||
torch_compile_options(torch_cuda) # see cmake/public/utils.cmake
|
||||
target_compile_definitions(torch_cuda PRIVATE USE_CUDA)
|
||||
target_compile_definitions(torch_cuda PRIVATE -DEXPORT_AOTI_FUNCTIONS)
|
||||
|
||||
if(USE_CUFILE)
|
||||
target_link_libraries(torch_cuda PRIVATE torch::cufile)
|
||||
|
|
@ -1053,6 +1055,7 @@ if(USE_XPU)
|
|||
add_library(torch_xpu ${Caffe2_XPU_SRCS})
|
||||
torch_compile_options(torch_xpu) # see cmake/public/utils.cmake
|
||||
target_compile_definitions(torch_xpu PRIVATE USE_XPU)
|
||||
target_compile_definitions(torch_xpu PRIVATE -DEXPORT_AOTI_FUNCTIONS)
|
||||
if(WIN32)
|
||||
target_compile_options(torch_xpu PRIVATE /permissive-)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -310,6 +310,7 @@ endif()
|
|||
|
||||
add_library(torch_python SHARED ${TORCH_PYTHON_SRCS})
|
||||
torch_compile_options(torch_python) # see cmake/public/utils.cmake
|
||||
target_compile_definitions(torch_python PRIVATE -DEXPORT_AOTI_FUNCTIONS)
|
||||
if(NOT WIN32)
|
||||
target_compile_options(torch_python PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CXX>: -fvisibility=default>)
|
||||
|
|
|
|||
|
|
@ -44,8 +44,11 @@
|
|||
// to symbol clashes at link time if libtorch is included in a DLL and binary
|
||||
// that depends on the DLL. As a short term fix, we don't export the symbols.
|
||||
// In the long term, this will need to be addressed when Windows is supported.
|
||||
// #define AOTI_TORCH_EXPORT __declspec(dllexport)
|
||||
#define AOTI_TORCH_EXPORT
|
||||
#ifdef EXPORT_AOTI_FUNCTIONS
|
||||
#define AOTI_TORCH_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define AOTI_TORCH_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else // !_WIN32
|
||||
#define AOTI_TORCH_EXPORT
|
||||
#endif // _WIN32
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user