Enable sleef for Win Arm64 (#144876)

Sleef module was disabled for Windows Arm64 on b021486405
This PR enables it again since the issue is no longer valid.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/144876
Approved by: https://github.com/albanD, https://github.com/malfet

Co-authored-by: Ozan Aydin <148207261+ozanMSFT@users.noreply.github.com>
This commit is contained in:
Irem Yuksel 2025-01-23 19:22:56 +00:00 committed by PyTorch MergeBot
parent 991a4b5925
commit 66bf7da446
4 changed files with 6 additions and 8 deletions

View File

@ -462,7 +462,7 @@ if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x|ppc64le)$")
list(APPEND ATen_CPU_DEPENDENCY_LIBS cpuinfo)
endif()
if(NOT EMSCRIPTEN AND NOT INTERN_BUILD_MOBILE AND NOT (MSVC AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64"))
if(NOT EMSCRIPTEN AND NOT INTERN_BUILD_MOBILE)
if(NOT MSVC)
# Bump up optimization level for sleef to -O1, since at -O0 the compiler
# excessively spills intermediate vector registers to the stack
@ -473,6 +473,8 @@ if(NOT EMSCRIPTEN AND NOT INTERN_BUILD_MOBILE AND NOT (MSVC AND CMAKE_SYSTEM_PRO
else()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O1")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
set(SLEEF_ARCH_AARCH64 ON)
endif()
if(NOT USE_SYSTEM_SLEEF)

View File

@ -1761,10 +1761,7 @@ if(BUILD_TEST)
endif()
else()
add_executable(${test_name}_${CPU_CAPABILITY} "${test_src}")
target_link_libraries(${test_name}_${CPU_CAPABILITY} torch_library gtest_main)
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
target_link_libraries(${test_name}_${CPU_CAPABILITY} sleef)
endif()
target_link_libraries(${test_name}_${CPU_CAPABILITY} torch_library sleef gtest_main)
endif()
target_include_directories(${test_name}_${CPU_CAPABILITY} PRIVATE $<INSTALL_INTERFACE:include>)
target_include_directories(${test_name}_${CPU_CAPABILITY} PRIVATE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)

View File

@ -778,7 +778,7 @@ def _get_torch_related_args(
if not aot_mode:
libraries.append("torch_python")
if _IS_WINDOWS and platform.machine().lower() != "arm64":
if _IS_WINDOWS:
libraries.append("sleef")
return include_dirs, libraries_dirs, libraries

View File

@ -4,7 +4,6 @@ import glob
import importlib
import importlib.abc
import os
import platform
import re
import shlex
import shutil
@ -1015,7 +1014,7 @@ def CppExtension(name, sources, *args, **kwargs):
if not kwargs.get('py_limited_api', False):
# torch_python uses more than the python limited api
libraries.append('torch_python')
if IS_WINDOWS and platform.machine().lower() != "arm64":
if IS_WINDOWS:
libraries.append("sleef")
kwargs['libraries'] = libraries