[Mlir-commits] [mlir] 18e616c - [mlir][shape] add value_of op
Jacques Pienaar
llvmlistbot at llvm.org
Thu Aug 18 13:29:05 PDT 2022
Author: Jacques Pienaar
Date: 2022-08-18T13:27:04-07:00
New Revision: 18e616c3f0dc56703f0dac0a3a55bc2447e0a4c6
URL: https://github.com/llvm/llvm-project/commit/18e616c3f0dc56703f0dac0a3a55bc2447e0a4c6
DIFF: https://github.com/llvm/llvm-project/commit/18e616c3f0dc56703f0dac0a3a55bc2447e0a4c6.diff
LOG: [mlir][shape] add value_of op
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D131976
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 9eebe4306a798..4570772c7d393 100644
--- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -639,6 +639,21 @@ def Shape_ShapeOfOp : Shape_Op<"shape_of",
}];
}
+def Shape_ValueOfOp : Shape_Op<"value_of", [NoSideEffect]> {
+ let summary = "Returns value of a !shape.value_shape operand";
+
+ let description = [{
+ The operation takes !shape.value_shape, a.k.a. (value, shape) tuple as an
+ argument, and returns its value. The behavior is undefined for unknown and
+ invalid arguments.
+ }];
+
+ let arguments = (ins Shape_ValueShapeType:$arg);
+ let results = (outs AnyShaped:$result);
+
+ let assemblyFormat = "$arg attr-dict `:` type($result)";
+}
+
def Shape_SizeToIndexOp : Shape_Op<"size_to_index", [
DeclareOpInterfaceMethods<CastOpInterface>, NoSideEffect
]> {
diff --git a/mlir/test/Dialect/Shape/ops.mlir b/mlir/test/Dialect/Shape/ops.mlir
index ab35a69cb0602..33da6b2f15022 100644
--- a/mlir/test/Dialect/Shape/ops.mlir
+++ b/mlir/test/Dialect/Shape/ops.mlir
@@ -97,6 +97,11 @@ func.func @test_shape_of(%arg0: tensor<?xf32>) -> tensor<?xindex> {
return %0 : tensor<?xindex>
}
+func.func @test_value_of(%arg0: !shape.value_shape) -> tensor<?xf32> {
+ %0 = shape.value_of %arg0 : tensor<?xf32>
+ return %0 : tensor<?xf32>
+}
+
func.func @test_constraints() {
%0 = shape.const_shape [] : !shape.shape
%1 = shape.const_shape [1, 2, 3] : !shape.shape
More information about the Mlir-commits
mailing list