[mlir][shape] Add assemblyFormat for `shape.add`.

Differential Revision: https://reviews.llvm.org/D81644
This commit is contained in:
Alexander Belyaev 2020-06-11 12:40:18 +02:00
parent d386297c67
commit 4e19ba4159
2 changed files with 3 additions and 1 deletions

View 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", []> {

View 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