[Mlir-commits] [mlir] e7ab36f - Change elided large constant syntax to make it more explicit
Mehdi Amini
llvmlistbot at llvm.org
Wed Jan 19 12:45:40 PST 2022
Author: Mehdi Amini
Date: 2022-01-19T20:41:42Z
New Revision: e7ab36f191108cb42e85702b9a90d92cefdff6ec
URL: https://github.com/llvm/llvm-project/commit/e7ab36f191108cb42e85702b9a90d92cefdff6ec
DIFF: https://github.com/llvm/llvm-project/commit/e7ab36f191108cb42e85702b9a90d92cefdff6ec.diff
LOG: Change elided large constant syntax to make it more explicit
When the printer is requested to elide large constant, we emit an opaque
attribute instead. This patch fills the dialect name with
"elided_large_const" instead of "_" to remove some user confusion when
they later try to consume it.
Differential Revision: https://reviews.llvm.org/D117711
Added:
Modified:
mlir/lib/IR/AsmPrinter.cpp
mlir/test/CAPI/ir.c
mlir/test/IR/pretty-attributes.mlir
mlir/test/python/ir/operation.py
Removed:
################################################################################
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 6c9977df101fb..97eca237cdb6b 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -1607,7 +1607,7 @@ static void printSymbolReference(StringRef symbolRef, raw_ostream &os) {
// accept the string "elided". The first string must be a registered dialect
// name and the latter must be a hex constant.
static void printElidedElementsAttr(raw_ostream &os) {
- os << R"(opaque<"_", "0xDEADBEEF">)";
+ os << R"(opaque<"elided_large_const", "0xDEADBEEF">)";
}
LogicalResult AsmPrinter::Impl::printAlias(Attribute attr) {
diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c
index 51e0c2b4bcd24..418d5a0aa3fe8 100644
--- a/mlir/test/CAPI/ir.c
+++ b/mlir/test/CAPI/ir.c
@@ -463,7 +463,7 @@ static void printFirstOfEach(MlirContext ctx, MlirOperation operation) {
mlirOperationPrintWithFlags(operation, flags, printToStderr, NULL);
fprintf(stderr, "\n");
// clang-format off
- // CHECK: Op print with all flags: %{{.*}} = "arith.constant"() {elts = opaque<"_", "0xDEADBEEF"> : tensor<4xi32>, value = 0 : index} : () -> index loc(unknown)
+ // CHECK: Op print with all flags: %{{.*}} = "arith.constant"() {elts = opaque<"elided_large_const", "0xDEADBEEF"> : tensor<4xi32>, value = 0 : index} : () -> index loc(unknown)
// clang-format on
mlirOpPrintingFlagsDestroy(flags);
diff --git a/mlir/test/IR/pretty-attributes.mlir b/mlir/test/IR/pretty-attributes.mlir
index d1d43a17b8625..8146608d4310d 100644
--- a/mlir/test/IR/pretty-attributes.mlir
+++ b/mlir/test/IR/pretty-attributes.mlir
@@ -5,17 +5,17 @@
// tensor which passes don't look at directly, this isn't an issue.
// RUN: mlir-opt %s -mlir-elide-elementsattrs-if-larger=2 | mlir-opt
-// CHECK: opaque<"_", "0xDEADBEEF"> : tensor<3xi32>
+// CHECK: opaque<"elided_large_const", "0xDEADBEEF"> : tensor<3xi32>
"test.dense_attr"() {foo.dense_attr = dense<[1, 2, 3]> : tensor<3xi32>} : () -> ()
// CHECK: dense<[1, 2]> : tensor<2xi32>
"test.non_elided_dense_attr"() {foo.dense_attr = dense<[1, 2]> : tensor<2xi32>} : () -> ()
-// CHECK: opaque<"_", "0xDEADBEEF"> : vector<1x1x10xf16>
+// CHECK: opaque<"elided_large_const", "0xDEADBEEF"> : vector<1x1x10xf16>
"test.sparse_attr"() {foo.sparse_attr = sparse<[[0, 0, 5]], -2.0> : vector<1x1x10xf16>} : () -> ()
-// CHECK: opaque<"_", "0xDEADBEEF"> : tensor<100xf32>
-"test.opaque_attr"() {foo.opaque_attr = opaque<"_", "0xEBFE"> : tensor<100xf32> } : () -> ()
+// CHECK: opaque<"elided_large_const", "0xDEADBEEF"> : tensor<100xf32>
+"test.opaque_attr"() {foo.opaque_attr = opaque<"elided_large_const", "0xEBFE"> : tensor<100xf32> } : () -> ()
// CHECK: dense<1> : tensor<3xi32>
"test.dense_splat"() {foo.dense_attr = dense<1> : tensor<3xi32>} : () -> ()
diff --git a/mlir/test/python/ir/operation.py b/mlir/test/python/ir/operation.py
index 12f08e9c2fda1..f7484920c65f3 100644
--- a/mlir/test/python/ir/operation.py
+++ b/mlir/test/python/ir/operation.py
@@ -555,7 +555,7 @@ def testOperationPrint():
print(bytes_value)
# Test get_asm with options.
- # CHECK: value = opaque<"_", "0xDEADBEEF"> : tensor<4xi32>
+ # CHECK: value = opaque<"elided_large_const", "0xDEADBEEF"> : tensor<4xi32>
# CHECK: "std.return"(%arg0) : (i32) -> () -:4:7
module.operation.print(
large_elements_limit=2,
More information about the Mlir-commits
mailing list