Skip to content

Commit 984ea22

Browse files
committed
enable cpp kernl building
1 parent 6a8887f commit 984ea22

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

setup.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -385,19 +385,16 @@ def get_extensions():
385385
extra_compile_args["cxx"].extend(
386386
["-O3" if not debug_mode else "-O0", "-fdiagnostics-color=always"]
387387
)
388-
389-
# TODO(future PR): make this work without using `TORCH_VERSION_AT_LEAST_2_7`,
390-
# because we should not be using anything from `torchao` to build `torchao`.
391-
# if use_cpu_kernels and is_linux and TORCH_VERSION_AT_LEAST_2_7:
392-
# if torch._C._cpu._is_avx512_supported():
393-
# extra_compile_args["cxx"].extend(
394-
# [
395-
# "-DCPU_CAPABILITY_AVX512",
396-
# "-march=native",
397-
# "-mfma",
398-
# "-fopenmp",
399-
# ]
400-
# )
388+
if use_cpu_kernels and is_linux and hasattr(torch._C._cpu, "_is_avx512_supported"):
389+
if torch._C._cpu._is_avx512_supported():
390+
extra_compile_args["cxx"].extend(
391+
[
392+
"-DCPU_CAPABILITY_AVX512",
393+
"-march=native",
394+
"-mfma",
395+
"-fopenmp",
396+
]
397+
)
401398

402399
if debug_mode:
403400
extra_compile_args["cxx"].append("-g")

0 commit comments

Comments
 (0)