forked from OSchip/llvm-project
[mlir][shape] Add assemblyFormat for `shape.add`.
Differential Revision: https://reviews.llvm.org/D81644
This commit is contained in:
parent
d386297c67
commit
4e19ba4159
|
@ -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", []> {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue