Skip to content

Commit 100cf45

Browse files
[mlir][linalg][bufferize][NFC] Utilize DestinationStyleOpInterface helper
`DstBufferizableOpInterfaceExternalModel` provides suitable default implementations for Linalg ops. Differential Revision: https://reviews.llvm.org/D141921
1 parent c114dba commit 100cf45

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h"
1010
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
1111
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
12+
#include "mlir/Dialect/Bufferization/IR/DstBufferizableOpInterfaceImpl.h"
1213
#include "mlir/Dialect/Linalg/IR/Linalg.h"
1314
#include "mlir/Dialect/Tensor/IR/Tensor.h"
1415
#include "mlir/IR/Dialect.h"
@@ -89,8 +90,8 @@ bufferizeDestinationStyleOpInterface(RewriterBase &rewriter,
8990
/// operates entirely on memrefs.
9091
template <typename OpTy>
9192
struct LinalgOpInterface
92-
: public BufferizableOpInterface::ExternalModel<LinalgOpInterface<OpTy>,
93-
OpTy> {
93+
: public DstBufferizableOpInterfaceExternalModel<LinalgOpInterface<OpTy>,
94+
OpTy> {
9495
bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand,
9596
const AnalysisState &state) const {
9697
// Operand is read if it is used in the computation.
@@ -105,30 +106,6 @@ struct LinalgOpInterface
105106
return !bufferizableOp.getAliasingOpResult(opOperand, state).empty();
106107
}
107108

108-
SmallVector<OpOperand *>
109-
getAliasingOpOperand(Operation *op, OpResult opResult,
110-
const AnalysisState &state) const {
111-
auto genericOp = cast<DestinationStyleOpInterface>(op);
112-
113-
// The i-th OpResult may alias with the i-th "out" tensor.
114-
return {genericOp.getDpsInitOperand(opResult.getResultNumber())};
115-
}
116-
117-
SmallVector<OpResult> getAliasingOpResult(Operation *op, OpOperand &opOperand,
118-
const AnalysisState &state) const {
119-
auto genericOp = cast<DestinationStyleOpInterface>(op);
120-
121-
// The i-th "out" tensor may alias with the i-th OpResult.
122-
if (genericOp.isDpsInit(&opOperand))
123-
return {genericOp.getTiedOpResult(&opOperand)};
124-
return {};
125-
}
126-
127-
BufferRelation bufferRelation(Operation *op, OpResult opResult,
128-
const AnalysisState &state) const {
129-
return BufferRelation::Equivalent;
130-
}
131-
132109
LogicalResult bufferize(Operation *op, RewriterBase &rewriter,
133110
const BufferizationOptions &options) const {
134111
return bufferizeDestinationStyleOpInterface(

0 commit comments

Comments
 (0)