Summary:
- Mark it NoSideEffect
- Add custom parser/printer
Differential Revision: https://reviews.llvm.org/D79684
}
def Shape_ShapeOfOp : Shape_Op<"shape_of",
- [DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
+ [NoSideEffect, DeclareOpInterfaceMethods<InferTypeOpInterface>]> {
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;
}
%1 = shape.const_shape [1, 2, 3]
return
}
+
+func @test_shape_of(%arg0: tensor<?xf32>) -> !shape.shape {
+ %0 = shape.shape_of %arg0 : tensor<?xf32>
+ return %0 : !shape.shape
+}