Skip to content

Commit 39848d0

Browse files
authored
Revert "[mlir] Remove dialect specific bufferization passes" (#93528)
Reverts #93488 Buildbot failure: https://lab.llvm.org/buildbot/#/builders/220/builds/39911
1 parent cbed9a6 commit 39848d0

File tree

32 files changed

+426
-10
lines changed

32 files changed

+426
-10
lines changed

mlir/include/mlir/Dialect/Arith/Transforms/Passes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ namespace arith {
2424
class WideIntEmulationConverter;
2525
class NarrowTypeEmulationConverter;
2626

27+
/// Create a pass to bufferize arith.constant ops.
28+
std::unique_ptr<Pass> createConstantBufferizePass(uint64_t alignment = 0);
29+
2730
/// Adds patterns to emulate wide Arith and Function ops over integer
2831
/// types into supported ones. This is done by splitting original power-of-two
2932
/// i2N integer types into two iN halves.

mlir/include/mlir/Dialect/Arith/Transforms/Passes.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111

1212
include "mlir/Pass/PassBase.td"
1313

14+
def ArithBufferizePass : Pass<"arith-bufferize", "ModuleOp"> {
15+
let summary = "Bufferize Arith dialect ops.";
16+
let description = [{
17+
This pass bufferizes arith dialect ops.
18+
19+
This pass needs to be a module pass because it inserts memref.global
20+
ops into the module, which cannot be done safely from a function pass due to
21+
multi-threading. Most other bufferization passes can run in parallel at
22+
function granularity.
23+
}];
24+
let options = [
25+
Option<"alignment", "alignment", "unsigned", /*default=*/"0",
26+
"Create global memrefs with a specified alignment">,
27+
];
28+
}
29+
1430
def ArithExpandOpsPass : Pass<"arith-expand"> {
1531
let summary = "Legalize Arith ops to be convertible to LLVM.";
1632
let dependentDialects = ["vector::VectorDialect"];

mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ createPromoteBuffersToStackPass(std::function<bool(Value)> isSmallAlloc);
221221
/// insert_slice ops.
222222
std::unique_ptr<Pass> createEmptyTensorEliminationPass();
223223

224+
/// Create a pass that bufferizes ops from the bufferization dialect.
225+
std::unique_ptr<Pass> createBufferizationBufferizePass();
226+
224227
//===----------------------------------------------------------------------===//
225228
// Registration
226229
//===----------------------------------------------------------------------===//

mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ def FinalizingBufferize : Pass<"finalizing-bufferize", "func::FuncOp"> {
350350
let constructor = "mlir::bufferization::createFinalizingBufferizePass()";
351351
}
352352

353+
def BufferizationBufferize : Pass<"bufferization-bufferize", "func::FuncOp"> {
354+
let summary = "Bufferize the `bufferization` dialect";
355+
let constructor = "mlir::bufferization::createBufferizationBufferizePass()";
356+
}
357+
353358
def DropEquivalentBufferResults : Pass<"drop-equivalent-buffer-results", "ModuleOp"> {
354359
let summary = "Remove MemRef return values that are equivalent to a bbArg";
355360
let description = [{

mlir/include/mlir/Dialect/Linalg/Passes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ namespace func {
2222
class FuncOp;
2323
} // namespace func
2424

25+
namespace bufferization {
26+
struct OneShotBufferizationOptions;
27+
} // namespace bufferization
28+
2529
#define GEN_PASS_DECL
2630
#include "mlir/Dialect/Linalg/Passes.h.inc" // IWYU pragma: keep
2731

mlir/include/mlir/Dialect/Linalg/Passes.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ def LinalgInlineScalarOperandsPass : Pass<"linalg-inline-scalar-operands"> {
8989
];
9090
}
9191

92+
def LinalgBufferizePass : Pass<"linalg-bufferize"> {
93+
let summary = "Bufferize the linalg dialect";
94+
let dependentDialects = [
95+
"affine::AffineDialect",
96+
"bufferization::BufferizationDialect",
97+
"linalg::LinalgDialect",
98+
"memref::MemRefDialect",
99+
];
100+
}
101+
92102
def LinalgGeneralizeNamedOpsPass : Pass<"linalg-generalize-named-ops"> {
93103
let summary = "Convert named ops into generic ops";
94104
let dependentDialects = ["linalg::LinalgDialect"];

mlir/include/mlir/Dialect/Shape/Transforms/Passes.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ void populateShapeRewritePatterns(RewritePatternSet &patterns);
4747
void populateRemoveShapeConstraintsPatterns(RewritePatternSet &patterns);
4848
std::unique_ptr<OperationPass<func::FuncOp>> createRemoveShapeConstraintsPass();
4949

50+
// Bufferizes shape dialect ops.
51+
//
52+
// Note that most shape dialect ops must be converted to std before
53+
// bufferization happens, as they are intended to be bufferized at the std
54+
// level.
55+
std::unique_ptr<OperationPass<func::FuncOp>> createShapeBufferizePass();
56+
5057
/// Outline the shape computation part by adding shape.func and populate
5158
/// conrresponding mapping infomation into ShapeMappingAnalysis.
5259
std::unique_ptr<OperationPass<ModuleOp>> createOutlineShapeComputationPass();

mlir/include/mlir/Dialect/Shape/Transforms/Passes.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,11 @@ def ShapeToShapeLowering : Pass<"shape-to-shape-lowering", "func::FuncOp"> {
103103
let constructor = "mlir::createShapeToShapeLowering()";
104104
}
105105

106+
// TODO: Generalize this to allow any type conversions desired.
107+
def ShapeBufferize : Pass<"shape-bufferize", "func::FuncOp"> {
108+
let summary = "Bufferize the shape dialect.";
109+
let constructor = "mlir::createShapeBufferizePass()";
110+
let dependentDialects = ["bufferization::BufferizationDialect",
111+
"memref::MemRefDialect"];
112+
}
106113
#endif // MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES

mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ namespace tensor {
2121
/// Creates an instance of the `tensor` subset folding pass.
2222
std::unique_ptr<Pass> createFoldTensorSubsetOpsPass();
2323

24+
/// Creates an instance of the `tensor` dialect bufferization pass.
25+
std::unique_ptr<Pass> createTensorBufferizePass();
26+
2427
//===----------------------------------------------------------------------===//
2528
// Registration
2629
//===----------------------------------------------------------------------===//

mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ def FoldTensorSubsetOps : Pass<"fold-tensor-subset-ops"> {
2727
];
2828
}
2929

30+
def TensorBufferize : Pass<"tensor-bufferize", "func::FuncOp"> {
31+
let summary = "Bufferize the `tensor` dialect";
32+
let constructor = "mlir::tensor::createTensorBufferizePass()";
33+
}
34+
3035
#endif // MLIR_DIALECT_TENSOR_TRANSFORMS_PASSES

0 commit comments

Comments
 (0)