Skip to content

Commit

Permalink
Fix builds for TVM
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Oct 17, 2024
1 parent f98e17d commit 5d619be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tvm/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions tvm/tvm-llvm.patch
Original file line number Diff line number Diff line change
@@ -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<String, IntImm> {
+#if TVM_LLVM_VERSION >= 190
+ Map<String, IntImm> 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<bool> features;
if (llvm::sys::getHostCPUFeatures(features)) {
Map<String, IntImm> 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 {};
});

0 comments on commit 5d619be

Please sign in to comment.