[mlir][shape] Add assemblyFormat for `shape.add`.
authorAlexander Belyaev <pifon@google.com>
Thu, 11 Jun 2020 10:40:18 +0000 (12:40 +0200)
committerAlexander Belyaev <pifon@google.com>
Thu, 11 Jun 2020 16:35:05 +0000 (18:35 +0200)
Differential Revision: https://reviews.llvm.org/D81644

mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/test/Dialect/Shape/ops.mlir

index 334a15b..78b86bf 100644 (file)
@@ -63,6 +63,8 @@ def Shape_AddOp : Shape_Op<"add", [SameOperandsAndResultType]> {
 
   let arguments = (ins Shape_SizeType:$lhs, Shape_SizeType:$rhs);
   let results = (outs Shape_SizeType:$result);
+
+  let assemblyFormat = "$lhs `,` $rhs attr-dict";
 }
 
 def Shape_BroadcastOp : Shape_Op<"broadcast", []> {
index a666818..a6718c7 100644 (file)
@@ -9,7 +9,7 @@ func @shape_num_elements(%shape : !shape.shape) -> !shape.size {
   %init = shape.const_size 0
   %num_elements = shape.reduce(%shape, %init) -> !shape.size {
     ^bb0(%index: index, %dim: !shape.size, %lci: !shape.size):
-      %acc = "shape.add"(%lci, %dim) : (!shape.size, !shape.size) -> !shape.size
+      %acc = shape.add %lci, %dim
       shape.yield %acc : !shape.size
   }
   return %num_elements : !shape.size