[Mlir-commits] [mlir] 5a675f0 - [Mlir] Add assembly format for `shape.mul`.
Alexander Belyaev
llvmlistbot at llvm.org
Fri Jun 5 01:58:36 PDT 2020
Author: Alexander Belyaev
Date: 2020-06-05T10:55:54+02:00
New Revision: 5a675f0552b487d0f5d673a02195446c818143cb
URL: https://github.com/llvm/llvm-project/commit/5a675f0552b487d0f5d673a02195446c818143cb
DIFF: https://github.com/llvm/llvm-project/commit/5a675f0552b487d0f5d673a02195446c818143cb.diff
LOG: [Mlir] Add assembly format for `shape.mul`.
Differential Revision: https://reviews.llvm.org/D81194
Added:
Modified:
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/test/Dialect/Shape/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index e38b8ba55b5d..bfc4ecd66b76 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -267,6 +267,8 @@ def Shape_MulOp : Shape_Op<"mul", [SameOperandsAndResultType]> {
let arguments = (ins Shape_SizeType:$lhs, Shape_SizeType:$rhs);
let results = (outs Shape_SizeType:$result);
+
+ let assemblyFormat = "attr-dict $lhs `,` $rhs";
}
def Shape_NumElementsOp : Shape_Op<"num_elements", [NoSideEffect]> {
@@ -274,6 +276,10 @@ def Shape_NumElementsOp : Shape_Op<"num_elements", [NoSideEffect]> {
let description = [{
Returns the number of elements for a given shape which is the product of its
dimensions.
+
+ ```mlir
+ %product = shape.mul %lhs, %rhs
+ ```
}];
let arguments = (ins Shape_ShapeType:$shape);
diff --git a/mlir/test/Dialect/Shape/ops.mlir b/mlir/test/Dialect/Shape/ops.mlir
index 42eaf58a87ac..5ccd3ffba3ff 100644
--- a/mlir/test/Dialect/Shape/ops.mlir
+++ b/mlir/test/Dialect/Shape/ops.mlir
@@ -1,4 +1,8 @@
// RUN: mlir-opt -split-input-file %s | mlir-opt | FileCheck %s --dump-input-on-failure
+// Verify the printed output can be parsed.
+// RUN: mlir-opt %s | mlir-opt | FileCheck %s --dump-input-on-failure
+// Verify the generic form can be parsed.
+// RUN: mlir-opt -mlir-print-op-generic %s | mlir-opt | FileCheck %s --dump-input-on-failure
// CHECK-LABEL: shape_num_elements
func @shape_num_elements(%shape : !shape.shape) -> !shape.size {
@@ -80,3 +84,8 @@ func @test_constraints() {
}
return
}
+
+func @test_mul(%lhs: !shape.size, %rhs: !shape.size) -> !shape.size {
+ %product = shape.mul %lhs, %rhs
+ return %product: !shape.size
+}
More information about the Mlir-commits
mailing list