[Mlir-commits] [mlir] e4c74fd - Don't elide splat attributes during printing
Tamas Berghammer
llvmlistbot at llvm.org
Fri Nov 27 06:42:34 PST 2020
Author: Tamas Berghammer
Date: 2020-11-27T14:42:26Z
New Revision: e4c74fd9ddd90fd269620c0c669455dbd6b29bb9
URL: https://github.com/llvm/llvm-project/commit/e4c74fd9ddd90fd269620c0c669455dbd6b29bb9
DIFF: https://github.com/llvm/llvm-project/commit/e4c74fd9ddd90fd269620c0c669455dbd6b29bb9.diff
LOG: Don't elide splat attributes during printing
A splat attribute have a single element during printing so we should
treat it as such when we decide if we elide it or not based on the flag
intended to elide large attributes.
Reviewed By: rriddle, mehdi_amini
Differential Revision: https://reviews.llvm.org/D92165
Added:
Modified:
mlir/lib/IR/AsmPrinter.cpp
mlir/test/IR/pretty-attributes.mlir
Removed:
################################################################################
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 73d272cf5f22..9d3e26112200 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -158,7 +158,8 @@ OpPrintingFlags &OpPrintingFlags::useLocalScope() {
/// Return if the given ElementsAttr should be elided.
bool OpPrintingFlags::shouldElideElementsAttr(ElementsAttr attr) const {
return elementsAttrElementLimit.hasValue() &&
- *elementsAttrElementLimit < int64_t(attr.getNumElements());
+ *elementsAttrElementLimit < int64_t(attr.getNumElements()) &&
+ !attr.isa<SplatElementsAttr>();
}
/// Return the size limit for printing large ElementsAttr.
diff --git a/mlir/test/IR/pretty-attributes.mlir b/mlir/test/IR/pretty-attributes.mlir
index e4e5b34f0a6d..d4ac8e773935 100644
--- a/mlir/test/IR/pretty-attributes.mlir
+++ b/mlir/test/IR/pretty-attributes.mlir
@@ -16,3 +16,6 @@
// CHECK: opaque<"", "0xDEADBEEF"> : tensor<100xf32>
"test.opaque_attr"() {foo.opaque_attr = opaque<"", "0xEBFE"> : tensor<100xf32> } : () -> ()
+
+// CHECK: dense<1> : tensor<3xi32>
+"test.dense_splat"() {foo.dense_attr = dense<1> : tensor<3xi32>} : () -> ()
More information about the Mlir-commits
mailing list