forked from conda-forge/pytorch-cpu-feedstock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport patch for torchinductor failures on windows
- Loading branch information
1 parent
ceb0114
commit cb47ade
Showing
17 changed files
with
83 additions
and
15 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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0001-Force-usage-of-python-3-and-error-without-numpy.patch
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
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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0006-Use-BLAS_USE_CBLAS_DOT-for-OpenBLAS-builds.patch
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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0009-simplify-torch.utils.cpp_extension.include_paths-use.patch
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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0010-point-include-paths-to-PREFIX-include.patch
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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0011-Add-conda-prefix-to-inductor-include-paths.patch
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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0012-make-ATEN_INCLUDE_DIR-relative-to-TORCH_INSTALL_PREF.patch
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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0013-remove-DESTINATION-lib-from-CMake-install-TARGETS-di.patch
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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0014-make-library-name-in-test_mutable_custom_op_fixed_la.patch
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
2 changes: 1 addition & 1 deletion
2
recipe/patches/0015-avoid-deprecated-find_package-CUDA-in-caffe2-CMake-m.patch
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
66 changes: 66 additions & 0 deletions
66
recipe/patches/0016-export-AOTI_TORCH_EXPORT-on-Windows.-140030.patch
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
From 2869f014b34cc01662a9c3542d11d53dafd0bb0a Mon Sep 17 00:00:00 2001 | ||
From: Xu Han <xu.han@outlook.com> | ||
Date: Wed, 15 Jan 2025 23:43:41 +0000 | ||
Subject: [PATCH 16/16] 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: | ||
![Image](https://github.com/user-attachments/assets/883846fb-8e92-4b9c-9400-daab32382a3a) | ||
|
||
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, https://github.com/malfet | ||
|
||
Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com> | ||
--- | ||
CMakeLists.txt | 3 +++ | ||
torch/csrc/inductor/aoti_torch/c/shim.h | 10 +++++++++- | ||
2 files changed, 12 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index c8af5f00b5c..c1733a99e91 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -1097,6 +1097,9 @@ if(NOT MSVC) | ||
append_cxx_flag_if_supported("-Wno-error=redundant-move" CMAKE_CXX_FLAGS) | ||
endif() | ||
else() | ||
+ # Define export functions for AOTI. | ||
+ add_compile_definitions(EXPORT_AOTI_FUNCTIONS) | ||
+ | ||
# skip unwanted includes from windows.h | ||
add_compile_definitions(WIN32_LEAN_AND_MEAN) | ||
# Windows SDK broke compatibility since version 25131, but introduced this | ||
diff --git a/torch/csrc/inductor/aoti_torch/c/shim.h b/torch/csrc/inductor/aoti_torch/c/shim.h | ||
index 4c6c9afcacc..b2202b24b91 100644 | ||
--- a/torch/csrc/inductor/aoti_torch/c/shim.h | ||
+++ b/torch/csrc/inductor/aoti_torch/c/shim.h | ||
@@ -44,8 +44,16 @@ | ||
// 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) | ||
+#ifdef OVRSOURCE | ||
+// Do not export AOTI on Windows for internal builds | ||
#define AOTI_TORCH_EXPORT | ||
+#else /* OVRSOURCE */ | ||
+#ifdef EXPORT_AOTI_FUNCTIONS | ||
+#define AOTI_TORCH_EXPORT __declspec(dllexport) | ||
+#else | ||
+#define AOTI_TORCH_EXPORT __declspec(dllimport) | ||
+#endif | ||
+#endif /* OVRSOURCE */ | ||
#else // !_WIN32 | ||
#define AOTI_TORCH_EXPORT | ||
#endif // _WIN32 |