diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td @@ -61,8 +61,8 @@ let assemblyFormat = "$min `:` $max `:` $step attr-dict `:` type(results)"; } -class Linalg_ReshapeLikeOp : - Linalg_Op { +class Linalg_ReshapeLikeOp traits = []> : + Linalg_Op { let builders = [ // Builders for a contracting reshape whose result type is computed from // `src` and `reassociation`. @@ -103,7 +103,8 @@ }]; } -def Linalg_ReshapeOp : Linalg_ReshapeLikeOp<"reshape">, +def Linalg_ReshapeOp : Linalg_ReshapeLikeOp<"reshape", [ + DeclareOpInterfaceMethods]>, 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 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -591,6 +591,8 @@ 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