forked from OSchip/llvm-project
[mlir][bufferization][NFC] Move EmptyTensorToAllocTensorPass
This change moves the pass from the Linalg dialect to the bufferization dialect. Differential Revision: https://reviews.llvm.org/D135130
This commit is contained in:
parent
e28b15b572
commit
129420df51
|
@ -46,6 +46,9 @@ LogicalResult promoteBufferResultsToOutParams(ModuleOp module);
|
|||
/// function argument.
|
||||
std::unique_ptr<Pass> createDropEquivalentBufferResultsPass();
|
||||
|
||||
/// Create a pass that rewrites tensor.empty to bufferization.alloc_tensor.
|
||||
std::unique_ptr<Pass> createEmptyTensorToAllocTensorPass();
|
||||
|
||||
/// Drop all memref function results that are equivalent to a function argument.
|
||||
LogicalResult dropEquivalentBufferResults(ModuleOp module);
|
||||
|
||||
|
|
|
@ -168,6 +168,17 @@ def DropEquivalentBufferResults : Pass<"drop-equivalent-buffer-results", "Module
|
|||
let dependentDialects = ["memref::MemRefDialect"];
|
||||
}
|
||||
|
||||
def EmptyTensorToAllocTensor : Pass<"empty-tensor-to-alloc-tensor"> {
|
||||
let summary = "Replace all empty ops by alloc_tensor ops.";
|
||||
let description = [{
|
||||
tensor.empty ops return a tensor of unspecified contents who's only purpose
|
||||
is to carry the tensor shape. This pass converts such ops to
|
||||
bufferization.alloc_tensor ops, which bufferize to buffer allocations.
|
||||
}];
|
||||
let constructor = "mlir::bufferization::createEmptyTensorToAllocTensorPass()";
|
||||
let dependentDialects = ["tensor::TensorDialect"];
|
||||
}
|
||||
|
||||
def OneShotBufferize : Pass<"one-shot-bufferize", "ModuleOp"> {
|
||||
let summary = "One-Shot Bufferize";
|
||||
let description = [{
|
||||
|
|
|
@ -61,9 +61,6 @@ createConvertLinalgToParallelLoopsPass();
|
|||
std::unique_ptr<OperationPass<func::FuncOp>>
|
||||
createConvertLinalgToAffineLoopsPass();
|
||||
|
||||
/// Create a pass that rewrites tensor.empty to bufferization.alloc_tensor.
|
||||
std::unique_ptr<Pass> createEmptyTensorToAllocTensorPass();
|
||||
|
||||
/// Create a pass to convert Linalg operations which work on tensors to use
|
||||
/// buffers instead.
|
||||
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgBufferizePass();
|
||||
|
|
|
@ -24,16 +24,6 @@ def ConvertElementwiseToLinalg : Pass<"convert-elementwise-to-linalg", ""> {
|
|||
let dependentDialects = ["linalg::LinalgDialect", "memref::MemRefDialect"];
|
||||
}
|
||||
|
||||
def EmptyTensorToAllocTensor : Pass<"empty-tensor-to-alloc-tensor"> {
|
||||
let summary = "Replace all empty ops by alloc_tensor ops.";
|
||||
let description = [{
|
||||
tensor.empty ops return a tensor of unspecified contents who's only purpose
|
||||
is to carry the tensor shape. This pass converts such ops to
|
||||
bufferization.alloc_tensor ops, which bufferize to buffer allocations.
|
||||
}];
|
||||
let constructor = "mlir::createEmptyTensorToAllocTensorPass()";
|
||||
}
|
||||
|
||||
def LinalgFoldUnitExtentDims : Pass<"linalg-fold-unit-extent-dims", ""> {
|
||||
let summary = "Remove unit-extent dimension in Linalg ops on tensors";
|
||||
let constructor = "mlir::createLinalgFoldUnitExtentDimsPass()";
|
||||
|
|
|
@ -7,6 +7,7 @@ add_mlir_dialect_library(MLIRBufferizationTransforms
|
|||
BufferUtils.cpp
|
||||
BufferViewFlowAnalysis.cpp
|
||||
DropEquivalentBufferResults.cpp
|
||||
EmptyTensorToAllocTensor.cpp
|
||||
FuncBufferizableOpInterfaceImpl.cpp
|
||||
OneShotAnalysis.cpp
|
||||
OneShotModuleBufferize.cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===- InitTensorToAllocTensor.cpp - Lower init_tensor to alloc_tensor ----===//
|
||||
//===- InitTensorToAllocTensor.cpp - Lower tensor.empty to alloc_tensor ---===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/Dialect/Linalg/Passes.h"
|
||||
#include "mlir/Dialect/Bufferization/Transforms/Passes.h"
|
||||
|
||||
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
|
||||
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
||||
|
@ -14,8 +14,10 @@
|
|||
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace bufferization {
|
||||
#define GEN_PASS_DEF_EMPTYTENSORTOALLOCTENSOR
|
||||
#include "mlir/Dialect/Linalg/Passes.h.inc"
|
||||
#include "mlir/Dialect/Bufferization/Transforms/Passes.h.inc"
|
||||
} // namespace bufferization
|
||||
} // namespace mlir
|
||||
|
||||
using namespace mlir;
|
||||
|
@ -35,7 +37,8 @@ struct EmptyTensorLoweringPattern : public OpRewritePattern<tensor::EmptyOp> {
|
|||
};
|
||||
|
||||
struct EmptyTensorToAllocTensor
|
||||
: public impl::EmptyTensorToAllocTensorBase<EmptyTensorToAllocTensor> {
|
||||
: public bufferization::impl::EmptyTensorToAllocTensorBase<
|
||||
EmptyTensorToAllocTensor> {
|
||||
EmptyTensorToAllocTensor() = default;
|
||||
|
||||
void runOnOperation() override;
|
||||
|
@ -55,6 +58,7 @@ void EmptyTensorToAllocTensor::runOnOperation() {
|
|||
signalPassFailure();
|
||||
}
|
||||
|
||||
std::unique_ptr<Pass> mlir::createEmptyTensorToAllocTensorPass() {
|
||||
std::unique_ptr<Pass>
|
||||
mlir::bufferization::createEmptyTensorToAllocTensorPass() {
|
||||
return std::make_unique<EmptyTensorToAllocTensor>();
|
||||
}
|
|
@ -15,7 +15,6 @@ add_mlir_dialect_library(MLIRLinalgTransforms
|
|||
Generalization.cpp
|
||||
Hoisting.cpp
|
||||
HoistPadding.cpp
|
||||
InitTensorToAllocTensor.cpp
|
||||
InlineScalarOperands.cpp
|
||||
Interchange.cpp
|
||||
Loops.cpp
|
||||
|
|
Loading…
Reference in New Issue