[Mlir-commits] [mlir] da289a1 - [mlir] Allow conversion to LLVM for ElementsAttr's with size 0
Sean Silva
llvmlistbot at llvm.org
Wed Jul 7 11:16:24 PDT 2021
Author: Sean Silva
Date: 2021-07-07T11:15:20-07:00
New Revision: da289a174fc6617c7be37be2947480510fd4f02a
URL: https://github.com/llvm/llvm-project/commit/da289a174fc6617c7be37be2947480510fd4f02a
DIFF: https://github.com/llvm/llvm-project/commit/da289a174fc6617c7be37be2947480510fd4f02a.diff
LOG: [mlir] Allow conversion to LLVM for ElementsAttr's with size 0
The code seems to correctly handle the case that this assertion was
guarding.
Differential Revision: https://reviews.llvm.org/D105379
Added:
Modified:
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Target/LLVMIR/llvmir.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index bbff0b0956c19..27f2e1e202523 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -180,8 +180,6 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
if (auto elementsAttr = attr.dyn_cast<ElementsAttr>()) {
assert(elementsAttr.getType().hasStaticShape());
- assert(elementsAttr.getNumElements() != 0 &&
- "unexpected empty elements attribute");
assert(!elementsAttr.getType().getShape().empty() &&
"unexpected empty elements attribute shape");
diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir
index 551fa7e76a93c..1c6339c1187fc 100644
--- a/mlir/test/Target/LLVMIR/llvmir.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir.mlir
@@ -18,6 +18,9 @@ llvm.mlir.global internal constant @i32_const(52: i53) : i53
// CHECK: @int_global_array = internal global [3 x i32] [i32 62, i32 62, i32 62]
llvm.mlir.global internal @int_global_array(dense<62> : vector<3xi32>) : !llvm.array<3 x i32>
+// CHECK: @int_global_array_zero_elements = internal constant [3 x [0 x [4 x float]]] zeroinitializer
+llvm.mlir.global internal constant @int_global_array_zero_elements(dense<> : tensor<3x0x4xf32>) : !llvm.array<3 x array<0 x array<4 x f32>>>
+
// CHECK: @i32_global_addr_space = internal addrspace(7) global i32 62
llvm.mlir.global internal @i32_global_addr_space(62: i32) {addr_space = 7 : i32} : i32
@@ -1585,4 +1588,3 @@ module {
// CHECK: ![[PIPELINE_DISABLE_NODE]] = !{!"llvm.loop.pipeline.disable", i1 true}
// CHECK: ![[II_NODE]] = !{!"llvm.loop.pipeline.initiationinterval", i32 2}
// CHECK: ![[ACCESS_GROUPS_NODE]] = !{![[GROUP_NODE1]], ![[GROUP_NODE2]]}
-
More information about the Mlir-commits
mailing list