[Mlir-commits] [mlir] b604544 - [mlir][shape] Tidy up shape.shape_of
Sean Silva
llvmlistbot at llvm.org
Mon May 11 12:56:43 PDT 2020
Author: Sean Silva
Date: 2020-05-11T12:55:31-07:00
New Revision: b6045448869a63dc7da3a4c87c124e85101220d7
URL: https://github.com/llvm/llvm-project/commit/b6045448869a63dc7da3a4c87c124e85101220d7
DIFF: https://github.com/llvm/llvm-project/commit/b6045448869a63dc7da3a4c87c124e85101220d7.diff
LOG: [mlir][shape] Tidy up shape.shape_of
Summary:
- Mark it NoSideEffect
- Add custom parser/printer
Differential Revision: https://reviews.llvm.org/D79684
Added:
Modified:
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/test/Dialect/Shape/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
index 6b64bb78bb85..3753213f9ab3 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<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;
}
diff --git a/mlir/test/Dialect/Shape/ops.mlir b/mlir/test/Dialect/Shape/ops.mlir
index 5ca3b0f49120..81c9afceef5f 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<?xf32>) -> !shape.shape {
+ %0 = shape.shape_of %arg0 : tensor<?xf32>
+ return %0 : !shape.shape
+}
More information about the Mlir-commits
mailing list