[Mlir-commits] [mlir] 100cf45 - [mlir][linalg][bufferize][NFC] Utilize DestinationStyleOpInterface helper

Matthias Springer llvmlistbot at llvm.org
Wed Jan 18 06:22:54 PST 2023


Author: Matthias Springer
Date: 2023-01-18T15:19:55+01:00
New Revision: 100cf456ff110f1290376f2bca9f2f254e5b528d

URL: https://github.com/llvm/llvm-project/commit/100cf456ff110f1290376f2bca9f2f254e5b528d
DIFF: https://github.com/llvm/llvm-project/commit/100cf456ff110f1290376f2bca9f2f254e5b528d.diff

LOG: [mlir][linalg][bufferize][NFC] Utilize DestinationStyleOpInterface helper

`DstBufferizableOpInterfaceExternalModel` provides suitable default implementations for Linalg ops.

Differential Revision: https://reviews.llvm.org/D141921

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.cpp
index c463e5fdf4179..f934a15588c30 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.cpp
@@ -9,6 +9,7 @@
 #include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h"
 #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
 #include "mlir/Dialect/Bufferization/IR/Bufferization.h"
+#include "mlir/Dialect/Bufferization/IR/DstBufferizableOpInterfaceImpl.h"
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Tensor/IR/Tensor.h"
 #include "mlir/IR/Dialect.h"
@@ -89,8 +90,8 @@ bufferizeDestinationStyleOpInterface(RewriterBase &rewriter,
 /// operates entirely on memrefs.
 template <typename OpTy>
 struct LinalgOpInterface
-    : public BufferizableOpInterface::ExternalModel<LinalgOpInterface<OpTy>,
-                                                    OpTy> {
+    : public DstBufferizableOpInterfaceExternalModel<LinalgOpInterface<OpTy>,
+                                                     OpTy> {
   bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand,
                               const AnalysisState &state) const {
     // Operand is read if it is used in the computation.
@@ -105,30 +106,6 @@ struct LinalgOpInterface
     return !bufferizableOp.getAliasingOpResult(opOperand, state).empty();
   }
 
-  SmallVector<OpOperand *>
-  getAliasingOpOperand(Operation *op, OpResult opResult,
-                       const AnalysisState &state) const {
-    auto genericOp = cast<DestinationStyleOpInterface>(op);
-
-    // The i-th OpResult may alias with the i-th "out" tensor.
-    return {genericOp.getDpsInitOperand(opResult.getResultNumber())};
-  }
-
-  SmallVector<OpResult> getAliasingOpResult(Operation *op, OpOperand &opOperand,
-                                            const AnalysisState &state) const {
-    auto genericOp = cast<DestinationStyleOpInterface>(op);
-
-    // The i-th "out" tensor may alias with the i-th OpResult.
-    if (genericOp.isDpsInit(&opOperand))
-      return {genericOp.getTiedOpResult(&opOperand)};
-    return {};
-  }
-
-  BufferRelation bufferRelation(Operation *op, OpResult opResult,
-                                const AnalysisState &state) const {
-    return BufferRelation::Equivalent;
-  }
-
   LogicalResult bufferize(Operation *op, RewriterBase &rewriter,
                           const BufferizationOptions &options) const {
     return bufferizeDestinationStyleOpInterface(


        


More information about the Mlir-commits mailing list