[mlir][bufferize][NFC] Consolidate transform header files
authorMatthias Springer <springerm@google.com>
Fri, 11 Nov 2022 12:49:02 +0000 (13:49 +0100)
committerMatthias Springer <springerm@google.com>
Fri, 11 Nov 2022 13:33:23 +0000 (14:33 +0100)
Differential Revision: https://reviews.llvm.org/D137830

mlir/include/mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h [deleted file]
mlir/include/mlir/Dialect/Bufferization/Transforms/Transforms.h [moved from mlir/include/mlir/Dialect/Bufferization/Transforms/EmptyTensorElimination.h with 64% similarity]
mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorToAllocTensor.cpp
mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
mlir/lib/Dialect/Bufferization/Transforms/TensorCopyInsertion.cpp

diff --git a/mlir/include/mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h b/mlir/include/mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h
deleted file mode 100644 (file)
index 658190b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-//===- TensorCopyInsertion.h - Resolve Bufferization Conflicts w/ Copies --===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_TENSORCOPYINSERTION_H
-#define MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_TENSORCOPYINSERTION_H
-
-#include "mlir/IR/Operation.h"
-
-namespace mlir {
-namespace bufferization {
-class AnalysisState;
-struct OneShotBufferizationOptions;
-
-LogicalResult insertTensorCopies(Operation *op,
-                                 const OneShotBufferizationOptions &options);
-
-LogicalResult insertTensorCopies(Operation *op, const AnalysisState &state);
-} // namespace bufferization
-} // namespace mlir
-
-#endif // MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_TENSORCOPYINSERTION_H
@@ -1,4 +1,4 @@
-//===- EmptyTensorElimination.h - tensor.empty op elimination -------------===//
+//===- Transforms.h - Bufferization and related transforms ------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,13 +6,16 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_EMPTYTENSORELIMINATION_H
-#define MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_EMPTYTENSORELIMINATION_H
+#ifndef MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_TRANSFORMS_H
+#define MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_TRANSFORMS_H
 
 #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
+#include "mlir/IR/Operation.h"
 
 namespace mlir {
 namespace bufferization {
+class AnalysisState;
+struct OneShotBufferizationOptions;
 
 /// A function that matches anchor OpOperands for tensor::EmptyOp elimination.
 /// If an OpOperand is matched, the function should populate the SmallVector
@@ -42,7 +45,22 @@ LogicalResult eliminateEmptyTensors(RewriterBase &rewriter, Operation *op,
 LogicalResult insertSliceAnchoredEmptyTensorEliminationStep(
     RewriterBase &rewriter, Operation *op, bufferization::AnalysisState &state);
 
+/// Resolve RaW and other conflicts by inserting bufferization.alloc_tensor ops.
+/// After applying this transform, the IR can be bufferized without inserting
+/// additional buffer allocations.
+LogicalResult insertTensorCopies(Operation *op,
+                                 const OneShotBufferizationOptions &options);
+
+/// Resolve RaW and other conflicts by inserting bufferization.alloc_tensor ops.
+/// After applying this transform, the IR can be bufferized without inserting
+/// additional buffer allocations.
+LogicalResult insertTensorCopies(Operation *op, const AnalysisState &state);
+
+/// Populate patterns to lower tensor.empty ops to bufferization.alloc_tensor
+/// ops.
+void populateEmptyTensorToAllocTensorPattern(RewritePatternSet &patterns);
+
 } // namespace bufferization
 } // namespace mlir
 
-#endif // MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_EMPTYTENSORELIMINATION_H
+#endif // MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_TRANSFORMS_H
index 25d2e51..e4355ad 100644 (file)
@@ -13,7 +13,7 @@
 #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
 #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
 #include "mlir/Dialect/Bufferization/Transforms/OneShotModuleBufferize.h"
-#include "mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h"
+#include "mlir/Dialect/Bufferization/Transforms/Transforms.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Dialect/MemRef/IR/MemRef.h"
 #include "mlir/IR/Operation.h"
index c85980e..b30fdca 100644 (file)
@@ -10,8 +10,8 @@
 
 #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
 #include "mlir/Dialect/Bufferization/IR/Bufferization.h"
-#include "mlir/Dialect/Bufferization/Transforms/EmptyTensorElimination.h"
 #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
+#include "mlir/Dialect/Bufferization/Transforms/Transforms.h"
 #include "mlir/Dialect/Tensor/IR/Tensor.h"
 #include "mlir/IR/Dominance.h"
 #include "mlir/Pass/Pass.h"
index 47f11c0..7670220 100644 (file)
@@ -9,6 +9,7 @@
 #include "mlir/Dialect/Bufferization/Transforms/Passes.h"
 
 #include "mlir/Dialect/Bufferization/IR/Bufferization.h"
+#include "mlir/Dialect/Bufferization/Transforms/Transforms.h"
 #include "mlir/Dialect/Tensor/IR/Tensor.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
@@ -50,10 +51,15 @@ struct EmptyTensorToAllocTensor
 };
 } // namespace
 
+void bufferization::populateEmptyTensorToAllocTensorPattern(
+    RewritePatternSet &patterns) {
+  patterns.insert<EmptyTensorLoweringPattern>(patterns.getContext());
+}
+
 void EmptyTensorToAllocTensor::runOnOperation() {
   Operation *op = getOperation();
   RewritePatternSet patterns(op->getContext());
-  patterns.insert<EmptyTensorLoweringPattern>(op->getContext());
+  populateEmptyTensorToAllocTensorPattern(patterns);
   if (failed(applyPatternsAndFoldGreedily(op, std::move(patterns))))
     signalPassFailure();
 }
index b93090d..6e02740 100644 (file)
@@ -46,7 +46,7 @@
 #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
 #include "mlir/Dialect/Bufferization/IR/Bufferization.h"
 #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
-#include "mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h"
+#include "mlir/Dialect/Bufferization/Transforms/Transforms.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Dialect/MemRef/IR/MemRef.h"
 #include "mlir/IR/AsmState.h"
index 2442337..badcf29 100644 (file)
@@ -64,7 +64,7 @@
 #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
 #include "mlir/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.h"
 #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
-#include "mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h"
+#include "mlir/Dialect/Bufferization/Transforms/Transforms.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Dialect/MemRef/IR/MemRef.h"
 #include "mlir/IR/Operation.h"
index 165f5bb..69ca30a 100644 (file)
@@ -13,7 +13,7 @@
 #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
 #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
 #include "mlir/Dialect/Bufferization/Transforms/OneShotModuleBufferize.h"
-#include "mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h"
+#include "mlir/Dialect/Bufferization/Transforms/Transforms.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 
 namespace mlir {