diff --git a/tvm/cppbuild.sh b/tvm/cppbuild.sh index 6ca89c7722..18dec681cd 100755 --- a/tvm/cppbuild.sh +++ b/tvm/cppbuild.sh @@ -104,6 +104,9 @@ sedinplace 's/find_opencl(${USE_OPENCL})/find_package(OpenCL REQUIRED)/g' cmake/ # https://github.com/apache/tvm/pull/6752 #patch -Np1 < ../../../tvm.patch +# https://github.com/apache/tvm/pull/17199 +patch -Np1 < ../../../tvm-llvm.patch + patch -Np1 < ../../../tvm-python.patch # Work around issues with llvm-config diff --git a/tvm/tvm-llvm.patch b/tvm/tvm-llvm.patch new file mode 100644 index 0000000000..23efd68d36 --- /dev/null +++ b/tvm/tvm-llvm.patch @@ -0,0 +1,29 @@ +diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc +index 6098a3f32..e21436e55 100644 +--- a/src/target/llvm/codegen_llvm.cc ++++ b/src/target/llvm/codegen_llvm.cc +@@ -2315,6 +2315,16 @@ TVM_REGISTER_GLOBAL("tvm.codegen.llvm.GetHostCPUName").set_body_typed([]() -> st + + TVM_REGISTER_GLOBAL("tvm.codegen.llvm.GetHostCPUFeatures") + .set_body_typed([]() -> Map { ++#if TVM_LLVM_VERSION >= 190 ++ Map ret; ++ auto features = llvm::sys::getHostCPUFeatures(); ++ for (auto it = features.begin(); it != features.end(); ++it) { ++ std::string name = it->getKey().str(); ++ bool value = it->getValue(); ++ ret.Set(name, IntImm(DataType::Bool(), value)); ++ } ++ return ret; ++#else + llvm::StringMap features; + if (llvm::sys::getHostCPUFeatures(features)) { + Map ret; +@@ -2325,6 +2335,7 @@ TVM_REGISTER_GLOBAL("tvm.codegen.llvm.GetHostCPUFeatures") + } + return ret; + } ++#endif + LOG(WARNING) << "Current version of LLVM does not support feature detection on your CPU"; + return {}; + });