From 452e2fc409df4acd790fcb53872db5a1b8c0130a Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Tue, 12 May 2020 13:40:00 -0700 Subject: [PATCH] Revert of Revert of [mlir][shape] Tidy up shape.shape_of Summary: - Mark it NoSideEffect - Add custom parser/printer This reverts the temporary revert in https://reviews.llvm.org/rG84a9c725742d26df04808a3c7349dbd98684c6cb That was a false alarm. A downstream test actually needed to be updated. --- mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td | 4 +++- mlir/test/Dialect/Shape/ops.mlir | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td index 2ce06b3..4f588f05 100644 --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td @@ -226,12 +226,14 @@ def Shape_ReduceOp : Shape_Op<"reduce", []> { } 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 index 5ca3b0f..81c9afc 100644 --- a/mlir/test/Dialect/Shape/ops.mlir +++ b/mlir/test/Dialect/Shape/ops.mlir @@ -62,3 +62,8 @@ func @test_parse_const_shape() { %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 +} -- 2.7.4