8000 [CpuInductor] Enable NEON ISA detection on Linux ARM by kit1980 · Pull Request #134165 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[CpuInductor] Enable NEON ISA detection on Linux ARM #134165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions torch/_inductor/codecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ class VecISA:
#include <ATen/cpu/vec/vec.h>
#endif

__attribute__((aligned(64))) float in_out_ptr0[16] = {0.0};
alignas(64) float in_out_ptr0[16] = {0.0};

extern "C" void __avx_chk_kernel() {
auto tmp0 = at::vec::Vectorized<float>(1);
Expand Down Expand Up @@ -1470,12 +1470,12 @@ def _check_and_append_supported_isa(
# we only cache some key isa information.
@functools.lru_cache(None)
def valid_vec_isa_list() -> List[VecISA]:
isa_list: List[VecISA] = []
if sys.platform == "darwin" and platform.processor() == "arm":
return [VecNEON()]
isa_list.append(VecNEON())

cur_os = sys.platform
if cur_os != "linux" and cur_os != "win32":
return []
if sys.platform not in ["linux", "win32"]:
return isa_list

if platform.machine() == "s390x":
with open("/proc/cpuinfo") as _cpu_info:
Expand All @@ -1488,14 +1488,19 @@ def valid_vec_isa_list() -> List[VecISA]:
if featuresmatch:
for group in featuresmatch.groups():
if re.search(r"[\^ ]+vxe[\$ ]+", group):
return [VecZVECTOR()]
return []

isa_list = []
_cpu_supported_isa = x86_isa_checker()
for isa in supported_vec_isa_list:
if str(isa) in _cpu_supported_isa and isa:
isa_list.append(isa)
isa_list.append(VecZVECTOR())
break
elif platform.machine() == "aarch64":
isa_list.append(VecNEON())
elif platform.machine() in ["x86_64", "AMD64"]:
"""
platform.machine() value is x86_64 on Linux, and the value is AMD64 on Windows.
"""
_cpu_supported_x86_isa = x86_isa_checker()
for isa in supported_vec_isa_list:
if str(isa) in _cpu_supported_x86_isa and isa:
isa_list.append(isa)

return isa_list


Expand Down
Loading
0