diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td @@ -226,12 +226,14 @@ } def Shape_ShapeOfOp : Shape_Op<"shape_of", - [DeclareOpInterfaceMethods]> { + [NoSideEffect, DeclareOpInterfaceMethods]> { let summary = "Returns shape of a value or shaped type operand"; let arguments = (ins AnyTypeOf<[AnyShaped, Shape_ValueShapeType]>:$arg); let results = (outs Shape_ShapeType:$result); + let assemblyFormat = "attr-dict $arg `:` type($arg)"; + let hasFolder = 1; } diff --git a/mlir/test/Dialect/Shape/ops.mlir b/mlir/test/Dialect/Shape/ops.mlir --- a/mlir/test/Dialect/Shape/ops.mlir +++ b/mlir/test/Dialect/Shape/ops.mlir @@ -62,3 +62,8 @@ %1 = shape.const_shape [1, 2, 3] return } + +func @test_shape_of(%arg0: tensor) -> !shape.shape { + %0 = shape.shape_of %arg0 : tensor + return %0 : !shape.shape +}