commit tvm for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package tvm for openSUSE:Factory checked in at 2021-05-01 00:46:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/tvm (Old) and /work/SRC/openSUSE:Factory/.tvm.new.1947 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "tvm" Sat May 1 00:46:53 2021 rev:8 rq:889541 version:0.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/tvm/tvm.changes 2021-02-16 22:49:36.450611173 +0100 +++ /work/SRC/openSUSE:Factory/.tvm.new.1947/tvm.changes 2021-05-01 00:46:57.479382702 +0200 @@ -1,0 +2,6 @@ +Fri Apr 30 09:08:14 UTC 2021 - Guillaume GARDET <guillaume.gardet@opensuse.org> + +- Backport patches to fix build on Tumbleweed with llvm12: + * tvm-fix-llvm12.patch + +------------------------------------------------------------------- New: ---- tvm-fix-llvm12.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ tvm.spec ++++++ --- /var/tmp/diff_new_pack.75ZMg5/_old 2021-05-01 00:46:57.951380599 +0200 +++ /var/tmp/diff_new_pack.75ZMg5/_new 2021-05-01 00:46:57.955380581 +0200 @@ -46,6 +46,8 @@ Patch1: tvm-fix-openblas.patch # PATCH-FIX-UPSTREAM - https://github.com/apache/tvm/issues/7319 Patch2: tvm-fix-catch.patch +# PATCH-FIX-UPSTREAM - https://github.com/apache/tvm/pull/6717 https://github.com/apache/tvm/pull/6738 +Patch3: tvm-fix-llvm12.patch BuildRequires: %{python_module Cython} BuildRequires: %{python_module attrs} BuildRequires: %{python_module decorator} @@ -98,8 +100,8 @@ Requires: libtvm = %{version} Requires: python3-scipy Requires: python3-typed-ast -Recommends: python3-onnx Recommends: python3-Pillow +Recommends: python3-onnx %description -n tvmc TVMC is a tool that exposes TVM features such as auto-tuning, compiling, ++++++ tvm-fix-llvm12.patch ++++++ From 388c22637d4b13611fa4105f8a5f709c5272d277 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek <kparzysz@quicinc.com> Date: Mon, 19 Oct 2020 17:21:03 -0500 Subject: [PATCH 1/2] [LLVM] Create fixed vector size according to latest LLVM12+ changes The vector handling code in LLVM keeps evolving to accommodate scalable vectors. As a result, code related to vector sizes changes quite often. --- src/target/llvm/codegen_llvm.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index cb04e6b8055b..40ec2cc9e0b8 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -475,7 +475,9 @@ llvm::Value* CodeGenLLVM::CreateBroadcast(llvm::Value* value, int lanes) { llvm::Constant* undef = llvm::UndefValue::get(type); llvm::Constant* zero = ConstInt32(0); value = builder_->CreateInsertElement(undef, value, zero); -#if TVM_LLVM_VERSION >= 110 +#if TVM_LLVM_VERSION >= 120 + llvm::Constant* mask = llvm::ConstantVector::getSplat(llvm::ElementCount::getFixed(lanes), zero); +#elif TVM_LLVM_VERSION >= 110 llvm::Constant* mask = llvm::ConstantVector::getSplat(llvm::ElementCount(lanes, /*Scalable=*/false), zero); #else From ec881f6ee2247c29a6b9480c34461928cd84e48c Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek <kparzysz@quicinc.com> Date: Mon, 19 Oct 2020 18:19:10 -0500 Subject: [PATCH 1/2] [LLVM] Avoid warnings when compiling getNumElements with LLVM12+ Extract the element-count code into GetVectorNumElements and make it compile cleanly with all LLVM versions. --- src/target/llvm/codegen_llvm.cc | 18 +++++++++--------- src/target/llvm/codegen_llvm.h | 14 ++++++++++++++ src/target/llvm/codegen_x86_64.cc | 6 +++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index 40ec2cc9e0b8..9bc56dc91458 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -487,7 +487,7 @@ llvm::Value* CodeGenLLVM::CreateBroadcast(llvm::Value* value, int lanes) { } llvm::Value* CodeGenLLVM::CreateVecSlice(llvm::Value* vec, int begin, int extent) { - int num_elems = llvm::cast<llvm::VectorType>(vec->getType())->getNumElements(); + int num_elems = GetVectorNumElements(vec); if (extent == num_elems && begin == 0) return vec; CHECK(begin >= 0 && extent <= num_elems) << "Slicing out of bound!\n"; std::vector<llvm::Constant*> indices; @@ -503,7 +503,7 @@ llvm::Value* CodeGenLLVM::CreateVecSlice(llvm::Value* vec, int begin, int extent } llvm::Value* CodeGenLLVM::CreateVecFlip(llvm::Value* vec) { - int num_elems = llvm::cast<llvm::VectorType>(vec->getType())->getNumElements(); + int num_elems = GetVectorNumElements(vec); #if TVM_LLVM_VERSION >= 110 std::vector<int> indices; #else @@ -517,7 +517,7 @@ llvm::Value* CodeGenLLVM::CreateVecFlip(llvm::Value* vec) { llvm::Value* CodeGenLLVM::CreateVecPad(llvm::Value* vec, int target_lanes) { llvm::Value* mask = llvm::UndefValue::get(DTypeToLLVMType(DataType::Int(32, target_lanes))); - int num_elems = llvm::cast<llvm::VectorType>(vec->getType())->getNumElements(); + int num_elems = GetVectorNumElements(vec); if (num_elems == target_lanes) return vec; CHECK_LT(num_elems, target_lanes); for (int i = 0; i < num_elems; ++i) { @@ -531,15 +531,15 @@ llvm::Value* CodeGenLLVM::CreateVecConcat(std::vector<llvm::Value*> vecs) { int total_lanes = 0; for (llvm::Value* v : vecs) { - total_lanes += llvm::cast<llvm::VectorType>(v->getType())->getNumElements(); + total_lanes += GetVectorNumElements(v); } while (vecs.size() > 1) { std::vector<llvm::Value*> new_vecs; for (size_t i = 0; i < vecs.size() - 1; i += 2) { llvm::Value* lhs = vecs[i]; llvm::Value* rhs = vecs[i + 1]; - const size_t lhs_lanes = llvm::cast<llvm::VectorType>(lhs->getType())->getNumElements(); - const size_t rhs_lanes = llvm::cast<llvm::VectorType>(rhs->getType())->getNumElements(); + const size_t lhs_lanes = GetVectorNumElements(lhs); + const size_t rhs_lanes = GetVectorNumElements(rhs); if (lhs_lanes < rhs_lanes) { lhs = CreateVecPad(lhs, rhs_lanes); } else if (rhs_lanes < lhs_lanes) { @@ -843,16 +843,16 @@ llvm::Value* CodeGenLLVM::CreateIntrinsic(const CallNode* op) { return builder_->CreateFCmpUNO(a, a); } else if (op->op.same_as(builtin::vectorlow())) { llvm::Value* v = MakeValue(op->args[0]); - int l = llvm::cast<llvm::VectorType>(v->getType())->getNumElements(); + int l = GetVectorNumElements(v); return CreateVecSlice(v, 0, l / 2); } else if (op->op.same_as(builtin::vectorhigh())) { llvm::Value* v = MakeValue(op->args[0]); - int l = llvm::cast<llvm::VectorType>(v->getType())->getNumElements(); + int l = GetVectorNumElements(v); return CreateVecSlice(v, l / 2, l / 2); } else if (op->op.same_as(builtin::vectorcombine())) { llvm::Value* v0 = MakeValue(op->args[0]); llvm::Value* v1 = MakeValue(op->args[1]); - int num_elems = llvm::cast<llvm::VectorType>(v0->getType())->getNumElements() * 2; + int num_elems = GetVectorNumElements(v0) * 2; #if TVM_LLVM_VERSION >= 110 std::vector<int> indices; #else diff --git a/src/target/llvm/codegen_llvm.h b/src/target/llvm/codegen_llvm.h index 3b0ce10534fd..78eb5e2dcac7 100644 --- a/src/target/llvm/codegen_llvm.h +++ b/src/target/llvm/codegen_llvm.h @@ -242,6 +242,11 @@ class CodeGenLLVM : public ExprFunctor<llvm::Value*(const PrimExpr&)>, */ llvm::Function* GetIntrinsicDecl(llvm::Intrinsic::ID id, llvm::Type* ret_type, llvm::ArrayRef<llvm::Type*> arg_types); + /*! + * \brief Get the number of elements in the given vector value. + * \param vec The value, must be of a vector type. + */ + inline int GetVectorNumElements(llvm::Value* vec); // initialize the function state. void InitFuncState(); // Get alignment given index. @@ -348,6 +353,15 @@ class CodeGenLLVM : public ExprFunctor<llvm::Value*(const PrimExpr&)>, */ static std::unique_ptr<DebugInfo> CreateDebugInfo(llvm::Module* module); }; + +inline int CodeGenLLVM::GetVectorNumElements(llvm::Value* vec) { +#if TVM_LLVM_VERSION >= 120 + return llvm::cast<llvm::FixedVectorType>(vec->getType())->getNumElements(); +#else + return llvm::cast<llvm::VectorType>(vec->getType())->getNumElements(); +#endif +} + } // namespace codegen } // namespace tvm #endif // LLVM_VERSION diff --git a/src/target/llvm/codegen_x86_64.cc b/src/target/llvm/codegen_x86_64.cc index f3362fb0f1eb..a71a0226c958 100644 --- a/src/target/llvm/codegen_x86_64.cc +++ b/src/target/llvm/codegen_x86_64.cc @@ -117,7 +117,11 @@ llvm::Value* CodeGenX86_64::CallVectorIntrin(llvm::Intrinsic::ID id, size_t intr llvm::Type* result_ty, const std::vector<llvm::Value*>& args) { llvm::Function* f = llvm::Intrinsic::getDeclaration(module_.get(), id, {}); +#if TVM_LLVM_VERSION >= 120 + size_t num_elems = llvm::cast<llvm::FixedVectorType>(result_ty)->getNumElements(); +#else size_t num_elems = llvm::cast<llvm::VectorType>(result_ty)->getNumElements(); +#endif if (intrin_lanes == num_elems) { return builder_->CreateCall(f, args); } @@ -130,7 +134,7 @@ llvm::Value* CodeGenX86_64::CallVectorIntrin(llvm::Intrinsic::ID id, size_t intr std::vector<llvm::Value*> split_args; for (const auto& v : args) { if (v->getType()->isVectorTy()) { - CHECK_EQ(llvm::cast<llvm::VectorType>(v->getType())->getNumElements(), num_elems); + CHECK_EQ(GetVectorNumElements(v), num_elems); split_args.push_back(CreateVecSlice(v, i, intrin_lanes)); } else { split_args.push_back(v);
participants (1)
-
Source-Sync