-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLIR][NFC] Retire let constructor
for Shape and MLProgram
#128869
[MLIR][NFC] Retire let constructor
for Shape and MLProgram
#128869
Conversation
`let constructor` is legacy (do not use in tree!) since the table gen backend emits most of the glue logic to build a pass. This PR retires the td method for Shape and MLProgram
@llvm/pr-subscribers-mlir-shape @llvm/pr-subscribers-mlir-mlprogram Author: lorenzo chelini (chelini) Changes
Full diff: https://github.com/llvm/llvm-project/pull/128869.diff 8 Files Affected:
diff --git a/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.h b/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.h
index 894e35e52724e..3acfb8373bc36 100644
--- a/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.h
@@ -23,8 +23,6 @@ namespace ml_program {
// Registration
//===----------------------------------------------------------------------===//
-std::unique_ptr<OperationPass<ModuleOp>> createMLProgramPipelineGlobalsPass();
-
/// Generate the code for registering passes.
#define GEN_PASS_REGISTRATION
#include "mlir/Dialect/MLProgram/Transforms/Passes.h.inc"
diff --git a/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.td b/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.td
index defe8191cb905..1e6361969c37e 100644
--- a/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.td
@@ -11,7 +11,7 @@
include "mlir/Pass/PassBase.td"
-def MLProgramPipelineGlobals : Pass<"mlprogram-pipeline-globals", "ModuleOp"> {
+def MLProgramPipelineGlobalsPass : Pass<"mlprogram-pipeline-globals", "ModuleOp"> {
let summary = "Optimize `ml_program` global operations for read and store";
let description = [{
`ml_program`'s load and store operations can be optimized for
@@ -21,7 +21,6 @@ def MLProgramPipelineGlobals : Pass<"mlprogram-pipeline-globals", "ModuleOp"> {
The pass is designed to handle both nested regions and function calls
safely.
}];
- let constructor = "mlir::ml_program::createMLProgramPipelineGlobalsPass()";
}
#endif // MLIR_DIALECT_MLPROGRAM_TRANSFORMS_PASSES
diff --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h
index 28e17459ff962..6312a655290a2 100644
--- a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h
@@ -30,11 +30,6 @@ namespace mlir {
#define GEN_PASS_DECL
#include "mlir/Dialect/Shape/Transforms/Passes.h.inc"
-/// Creates an instance of the ShapeToShapeLowering pass that legalizes Shape
-/// dialect to be convertible to Arith. For example, `shape.num_elements` get
-/// transformed to `shape.reduce`, which can be lowered to SCF and Arith.
-std::unique_ptr<Pass> createShapeToShapeLowering();
-
/// Collects a set of patterns to rewrite ops within the Shape dialect.
void populateShapeRewritePatterns(RewritePatternSet &patterns);
@@ -45,11 +40,6 @@ void populateShapeRewritePatterns(RewritePatternSet &patterns);
//
// After this pass, no cstr_ operations exist.
void populateRemoveShapeConstraintsPatterns(RewritePatternSet &patterns);
-std::unique_ptr<OperationPass<func::FuncOp>> createRemoveShapeConstraintsPass();
-
-/// Outline the shape computation part by adding shape.func and populate
-/// conrresponding mapping infomation into ShapeMappingAnalysis.
-std::unique_ptr<OperationPass<ModuleOp>> createOutlineShapeComputationPass();
//===----------------------------------------------------------------------===//
// Registration
diff --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td
index 83834509b4a35..b4b94e2e5fd43 100644
--- a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td
@@ -11,7 +11,7 @@
include "mlir/Pass/PassBase.td"
-def OutlineShapeComputation : Pass<"outline-shape-computation", "ModuleOp"> {
+def OutlineShapeComputationPass : Pass<"outline-shape-computation", "ModuleOp"> {
let summary = "Using shape.func to preserve shape computation";
let description = [{
This pass outlines the shape computation part in high level IR by adding
@@ -89,18 +89,15 @@ def OutlineShapeComputation : Pass<"outline-shape-computation", "ModuleOp"> {
// - Shape for: %1 = "test.concat"(%0, %arg1) {axis = 0 : i64} : (tensor<?x4x?xf32>, tensor<2x4x?xf32>) -> tensor<?x4x?xf32> :: @shape_cal_1(<block argument> of type 'tensor<?x4x?xf32>' at index: 0)
```
}];
- let constructor = "mlir::createOutlineShapeComputationPass()";
let dependentDialects = ["shape::ShapeDialect"];
}
-def RemoveShapeConstraints : Pass<"remove-shape-constraints", "func::FuncOp"> {
+def RemoveShapeConstraintsPass : Pass<"remove-shape-constraints", "func::FuncOp"> {
let summary = "Replace all cstr_ ops with a true witness";
- let constructor = "mlir::createRemoveShapeConstraintsPass()";
}
-def ShapeToShapeLowering : Pass<"shape-to-shape-lowering", "func::FuncOp"> {
+def ShapeToShapeLoweringPass : Pass<"shape-to-shape-lowering", "func::FuncOp"> {
let summary = "Legalize Shape dialect to be convertible to Arith";
- let constructor = "mlir::createShapeToShapeLowering()";
}
#endif // MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES
diff --git a/mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp b/mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp
index 27e89d69e214d..d3248ecdb5099 100644
--- a/mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp
+++ b/mlir/lib/Dialect/MLProgram/Transforms/PipelineGlobalOps.cpp
@@ -16,13 +16,13 @@
namespace mlir {
namespace ml_program {
-#define GEN_PASS_DEF_MLPROGRAMPIPELINEGLOBALS
+#define GEN_PASS_DEF_MLPROGRAMPIPELINEGLOBALSPASS
#include "mlir/Dialect/MLProgram/Transforms/Passes.h.inc"
namespace {
class MLProgramPipelineGlobals
- : public impl::MLProgramPipelineGlobalsBase<MLProgramPipelineGlobals> {
+ : public impl::MLProgramPipelineGlobalsPassBase<MLProgramPipelineGlobals> {
public:
void runOnOperation() override;
@@ -224,10 +224,5 @@ void MLProgramPipelineGlobals::runOnOperation() {
} // namespace
-std::unique_ptr<OperationPass<mlir::ModuleOp>>
-createMLProgramPipelineGlobalsPass() {
- return std::make_unique<MLProgramPipelineGlobals>();
-}
-
} // namespace ml_program
} // namespace mlir
diff --git a/mlir/lib/Dialect/Shape/Transforms/OutlineShapeComputation.cpp b/mlir/lib/Dialect/Shape/Transforms/OutlineShapeComputation.cpp
index e56742d52e131..97fadc9f31f47 100644
--- a/mlir/lib/Dialect/Shape/Transforms/OutlineShapeComputation.cpp
+++ b/mlir/lib/Dialect/Shape/Transforms/OutlineShapeComputation.cpp
@@ -23,7 +23,7 @@
#include <vector>
namespace mlir {
-#define GEN_PASS_DEF_OUTLINESHAPECOMPUTATION
+#define GEN_PASS_DEF_OUTLINESHAPECOMPUTATIONPASS
#include "mlir/Dialect/Shape/Transforms/Passes.h.inc"
} // namespace mlir
@@ -163,7 +163,7 @@ void constructShapeFunc(
}
struct OutlineShapeComputationPass
- : public impl::OutlineShapeComputationBase<OutlineShapeComputationPass> {
+ : public impl::OutlineShapeComputationPassBase<OutlineShapeComputationPass> {
void runOnOperation() override;
@@ -324,8 +324,3 @@ bool OutlineShapeComputationPass::calOnlyUsedByWithShapesRecursively(
}
} // namespace
-
-std::unique_ptr<OperationPass<ModuleOp>>
-mlir::createOutlineShapeComputationPass() {
- return std::make_unique<OutlineShapeComputationPass>();
-}
diff --git a/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp b/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
index d2b245f832e57..b2992d252cf6e 100644
--- a/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
+++ b/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
@@ -14,7 +14,7 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
namespace mlir {
-#define GEN_PASS_DEF_REMOVESHAPECONSTRAINTS
+#define GEN_PASS_DEF_REMOVESHAPECONSTRAINTSPASS
#include "mlir/Dialect/Shape/Transforms/Passes.h.inc"
} // namespace mlir
@@ -47,7 +47,7 @@ class RemoveCstrEqOp : public OpRewritePattern<shape::CstrEqOp> {
/// Removal pass.
class RemoveShapeConstraintsPass
- : public impl::RemoveShapeConstraintsBase<RemoveShapeConstraintsPass> {
+ : public impl::RemoveShapeConstraintsPassBase<RemoveShapeConstraintsPass> {
void runOnOperation() override {
MLIRContext &ctx = getContext();
@@ -65,8 +65,3 @@ void mlir::populateRemoveShapeConstraintsPatterns(RewritePatternSet &patterns) {
patterns.add<RemoveCstrBroadcastableOp, RemoveCstrEqOp>(
patterns.getContext());
}
-
-std::unique_ptr<OperationPass<func::FuncOp>>
-mlir::createRemoveShapeConstraintsPass() {
- return std::make_unique<RemoveShapeConstraintsPass>();
-}
diff --git a/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp b/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp
index e870664a742d8..121e0cc133e19 100644
--- a/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp
+++ b/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp
@@ -17,7 +17,7 @@
#include "mlir/Transforms/DialectConversion.h"
namespace mlir {
-#define GEN_PASS_DEF_SHAPETOSHAPELOWERING
+#define GEN_PASS_DEF_SHAPETOSHAPELOWERINGPASS
#include "mlir/Dialect/Shape/Transforms/Passes.h.inc"
} // namespace mlir
@@ -59,7 +59,7 @@ NumElementsOpConverter::matchAndRewrite(NumElementsOp op,
namespace {
struct ShapeToShapeLowering
- : public impl::ShapeToShapeLoweringBase<ShapeToShapeLowering> {
+ : public impl::ShapeToShapeLoweringPassBase<ShapeToShapeLowering> {
void runOnOperation() override;
};
} // namespace
@@ -81,7 +81,3 @@ void ShapeToShapeLowering::runOnOperation() {
void mlir::populateShapeRewritePatterns(RewritePatternSet &patterns) {
patterns.add<NumElementsOpConverter>(patterns.getContext());
}
-
-std::unique_ptr<Pass> mlir::createShapeToShapeLowering() {
- return std::make_unique<ShapeToShapeLowering>();
-}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Rename changes followed: - llvm/llvm-project#128751 - llvm/llvm-project#128869 --------- Signed-off-by: yzhang93 <zhyuhang88@gmail.com>
…8869) `let constructor` is legacy (do not use in tree!) since the table gen backend emits most of the glue logic to build a pass. This PR retires the td method for Shape and MLProgram
Rename changes followed: - llvm/llvm-project#128751 - llvm/llvm-project#128869 --------- Signed-off-by: yzhang93 <zhyuhang88@gmail.com> Signed-off-by: geomin12 <geomin12@amd.com>
let constructor
is legacy (do not use in tree!) since the table gen backend emits most of the glue logic to build a pass. This PR retires the td method for Shape and MLProgram