@@ -77,7 +77,6 @@ def test_something():
7777import textwrap
7878import time
7979import shutil
80- import subprocess
8180
8281from pathlib import Path
8382from typing import Optional , Callable , Union , List , Tuple
@@ -91,6 +90,7 @@ def test_something():
9190import tvm .te
9291import tvm ._ffi
9392
93+ from tvm .target import codegen
9494from tvm .contrib import nvcc , cudnn , rocm
9595import tvm .contrib .hexagon ._ci_env_check as hexagon
9696from tvm .driver .tvmc .frontends import load_model
@@ -1002,76 +1002,43 @@ def _corstone300_compile_time_check():
10021002requires_vitis_ai = Feature ("vitis_ai" , "Vitis AI" , cmake_flag = "USE_VITIS_AI" )
10031003
10041004
1005- def _arm_dot_supported ():
1006- arch = platform .machine ()
1005+ # check cpu features
1006+ def _has_cpu_feat (features ):
1007+ cpu = codegen .llvm_get_system_cpu ()
1008+ triple = codegen .llvm_get_system_triple ()
1009+ target = "llvm -mtriple=%s -mcpu=%s" % (triple , cpu )
1010+ has_feat = codegen .target_has_features (features , tvm .target .Target (target ))
10071011
1008- if arch not in ["arm64" , "aarch64" ]:
1009- return False
1012+ return has_feat
10101013
1011- if sys .platform .startswith ("darwin" ):
1012- cpu_info = subprocess .check_output ("sysctl -a" , shell = True ).strip ().decode ()
1013- for line in cpu_info .split ("\n " ):
1014- if line .startswith ("hw.optional.arm.FEAT_DotProd" ):
1015- return bool (int (line .split (":" , 1 )[1 ]))
1016- elif sys .platform .startswith ("linux" ):
1017- return True
10181014
1019- return False
1020-
1021-
1022- def _is_intel ():
1023- # Only linux is supported for now.
1024- if sys .platform .startswith ("linux" ):
1025- with open ("/proc/cpuinfo" , "r" ) as content :
1026- return "Intel" in content .read ()
1027-
1028- return False
1029-
1030-
1031- def _has_vnni ():
1032- arch = platform .machine ()
1033- # Only linux is supported for now.
1034- if arch == "x86_64" and sys .platform .startswith ("linux" ):
1035- with open ("/proc/cpuinfo" , "r" ) as content :
1036- return "avx512_vnni" in content .read ()
1037-
1038- return False
1039-
1040-
1041- # check avx512 intrinsic groups for SkyLake X
1042- def _has_slavx512 ():
1043- # Check LLVM support
1044- llvm_version = tvm .target .codegen .llvm_version_major ()
1045- is_llvm_support = llvm_version >= 8
1046- arch = platform .machine ()
1047- # Only linux is supported for now.
1048- if arch == "x86_64" and sys .platform .startswith ("linux" ):
1049- with open ("/proc/cpuinfo" , "r" ) as content :
1050- ctx = content .read ()
1051- check = (
1052- "avx512f" in ctx
1053- and "avx512cd" in ctx
1054- and "avx512bw" in ctx
1055- and "avx512dq" in ctx
1056- and "avx512vl" in ctx
1057- )
1058- return check and is_llvm_support
1059-
1060- return False
1015+ requires_arm_dot = Feature (
1016+ "arm_dot" ,
1017+ "ARM dot product" ,
1018+ run_time_check = lambda : _has_cpu_feat ("dotprod" ),
1019+ )
10611020
10621021
1063- requires_arm_dot = Feature ("arm_dot" , "ARM dot product" , run_time_check = _arm_dot_supported )
1022+ requires_x86_vnni = Feature (
1023+ "x86_vnni" ,
1024+ "x86 VNNI Extensions" ,
1025+ run_time_check = lambda : (_has_cpu_feat ("avx512vnni" ) or _has_cpu_feat ("avxvnni" )),
1026+ )
10641027
10651028
1066- requires_cascadelake = Feature (
1067- "cascadelake" , "x86 CascadeLake" , run_time_check = lambda : _has_vnni () and _is_intel ()
1029+ requires_x86_avx512 = Feature (
1030+ "x86_avx512" ,
1031+ "x86 AVX512 Extensions" ,
1032+ run_time_check = lambda : _has_cpu_feat (
1033+ ["avx512bw" , "avx512cd" , "avx512dq" , "avx512vl" , "avx512f" ]
1034+ ),
10681035)
10691036
10701037
1071- requires_skylake_avx512 = Feature (
1072- "skylake_avx512 " ,
1073- "x86 SkyLake AVX512 " ,
1074- run_time_check = lambda : _has_slavx512 () and _is_intel ( ),
1038+ requires_x86_amx = Feature (
1039+ "x86_amx " ,
1040+ "x86 AMX Extensions " ,
1041+ run_time_check = lambda : _has_cpu_feat ( "amx-int8" ),
10751042)
10761043
10771044
0 commit comments