Skip to content

Commit b604544

Browse files
committed
[mlir][shape] Tidy up shape.shape_of
Summary: - Mark it NoSideEffect - Add custom parser/printer Differential Revision: https://reviews.llvm.org/D79684
1 parent 98eead8 commit b604544

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,14 @@ def Shape_ReduceOp : Shape_Op<"reduce", []> {
226226
}
227227

228228
def Shape_ShapeOfOp : Shape_Op<"shape_of",
229-
[DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
229+
[NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
230230
let summary = "Returns shape of a value or shaped type operand";
231231

232232
let arguments = (ins AnyTypeOf<[AnyShaped, Shape_ValueShapeType]>:$arg);
233233
let results = (outs Shape_ShapeType:$result);
234234

235+
let assemblyFormat = "attr-dict $arg `:` type($arg)";
236+
235237
let hasFolder = 1;
236238
}
237239

mlir/test/Dialect/Shape/ops.mlir

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ func @test_parse_const_shape() {
6262
%1 = shape.const_shape [1, 2, 3]
6363
return
6464
}
65+
66+
func @test_shape_of(%arg0: tensor<?xf32>) -> !shape.shape {
67+
%0 = shape.shape_of %arg0 : tensor<?xf32>
68+
return %0 : !shape.shape
69+
}

0 commit comments

Comments
 (0)