8000 [cpp_extension][inductor] Fix sleef windows depends. (#128770) (#128811) · pytorch/pytorch@04e98d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04e98d3

Browse files
authored
[cpp_extension][inductor] Fix sleef windows depends. (#128770) (#128811)
# Issue: During I'm working on enable inductor on PyTorch Windows, I found the sleef lib dependency issue. <img width="1011" alt="image" src="https://github.com/pytorch/pytorch/assets/8433590/423bd854-3c5f-468f-9a64-a392d9b514e3"> # Analysis: After we enabled SIMD on PyTorch Windows(#118980 ), the sleef functions are called from VEC headers. It bring the sleef to the dependency. Here is a different between Windows and Linux OS. ## Linux : Linux is default export its functions, so libtorch_cpu.so static link to sleef.a, and then It also export sleef's functions. <img width="647" alt="image" src="https://github.com/pytorch/pytorch/assets/8433590/00ac536c-33fc-4943-a435-25590508840d"> ## Windows: Windows is by default not export its functions, and have many limitation to export functions, reference: #80604 We can't package sleef functions via torch_cpu.dll like Linux. # Solution: Acturally, we also packaged sleef static lib as a part of release. We just need to help user link to sleef.lib, it should be fine. 1. Add sleef to cpp_builder for inductor. 2. Add sleef to cpp_extension for C++ extesion. Pull Request resolved: #128770 Approved by: https://github.com/jgong5, https://github.com/jansel
1 parent 699c056 commit 04e98d3

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

torch/_inductor/cpp_builder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@ def _get_torch_related_args(include_pytorch: bool, aot_mode: bool):
571571
if not aot_mode:
572572
libraries.append("torch_python")
573573

574+
if _IS_WINDOWS:
575+
libraries.append("sleef")
576+
574577
# Unconditionally import c10 for non-abi-compatible mode to use TORCH_CHECK - See PyTorch #108690
575578
if not config.abi_compatible:
576579
libraries.append("c10")

torch/utils/cpp_extension.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,9 @@ def CppExtension(name, sources, *args, **kwargs):
961961
libraries.append('torch')
962962
libraries.append('torch_cpu')
963963
libraries.append('torch_python')
964+
if IS_WINDOWS:
965+
libraries.append("sleef")
966+
964967
kwargs['libraries'] = libraries
965968

966969
kwargs['language'] = 'c++'

0 commit comments

Comments
 (0)
0