[PATCH] D92165: Don't elide splat attributes during printing

Tamas Berghammer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 26 03:09:34 PST 2020


tberghammer created this revision.
tberghammer added a reviewer: rriddle.
Herald added subscribers: teijeong, rdzhabarov, tatianashp, jdoerfert, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, mehdi_amini.
Herald added a project: MLIR.
tberghammer requested review of this revision.
Herald added subscribers: stephenneuendorffer, nicolasvasilache.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92165

Files:
  mlir/lib/IR/AsmPrinter.cpp
  mlir/test/IR/pretty-attributes.mlir


Index: mlir/test/IR/pretty-attributes.mlir
===================================================================
--- mlir/test/IR/pretty-attributes.mlir
+++ 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>} : () -> ()
Index: mlir/lib/IR/AsmPrinter.cpp
===================================================================
--- mlir/lib/IR/AsmPrinter.cpp
+++ mlir/lib/IR/AsmPrinter.cpp
@@ -158,7 +158,8 @@
 /// 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.isa<SplatElementsAttr>() ? 1 : attr.getNumElements());
 }
 
 /// Return the size limit for printing large ElementsAttr.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92165.307809.patch
Type: text/x-patch
Size: 1091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201126/6d6e363a/attachment.bin>


More information about the llvm-commits mailing list