[Mlir-commits] [mlir] 1919c8b - Make linalg::ReshapeOp implement ViewLikeOpInterface
Stephan Herhut
llvmlistbot at llvm.org
Wed Jul 15 00:24:39 PDT 2020
Author: Stephan Herhut
Date: 2020-07-15T09:24:15+02:00
New Revision: 1919c8bfe8379402401da52d84d5397233cab8b9
URL: https://github.com/llvm/llvm-project/commit/1919c8bfe8379402401da52d84d5397233cab8b9
DIFF: https://github.com/llvm/llvm-project/commit/1919c8bfe8379402401da52d84d5397233cab8b9.diff
LOG: Make linalg::ReshapeOp implement ViewLikeOpInterface
Summary: A reshape aliases its input memref, so it acts like a view.
Differential Revision: https://reviews.llvm.org/D83773
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
index c58834c28530..1366e920039b 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
@@ -61,8 +61,8 @@ def Linalg_RangeOp :
let assemblyFormat = "$min `:` $max `:` $step attr-dict `:` type(results)";
}
-class Linalg_ReshapeLikeOp<string mnemonic> :
- Linalg_Op<mnemonic, [NoSideEffect]> {
+class Linalg_ReshapeLikeOp<string mnemonic, list<OpTrait> traits = []> :
+ Linalg_Op<mnemonic, !listconcat(traits, [NoSideEffect])> {
let builders = [
// Builders for a contracting reshape whose result type is computed from
// `src` and `reassociation`.
@@ -103,7 +103,8 @@ class Linalg_ReshapeLikeOp<string mnemonic> :
}];
}
-def Linalg_ReshapeOp : Linalg_ReshapeLikeOp<"reshape">,
+def Linalg_ReshapeOp : Linalg_ReshapeLikeOp<"reshape",
+ [DeclareOpInterfaceMethods<ViewLikeOpInterface>]>,
Arguments<(ins AnyStridedMemRef:$src, AffineMapArrayAttr:$reassociation)>,
Results<(outs AnyStridedMemRef:$result)> {
let summary = "linalg.reshape produces a new view into the operand view";
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 18ea31571aa4..7865add3663d 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -591,6 +591,8 @@ void mlir::linalg::ReshapeOp::build(OpBuilder &b, OperationState &result,
b.getAffineMapArrayAttr(maps));
}
+Value mlir::linalg::ReshapeOp::getViewSource() { return src(); }
+
// Common verifier for reshape-like types. Fills `expandedType` and
// `collapsedType` with the proper `src` or `result` type.
template <typename Op, typename T>
More information about the Mlir-commits
mailing list