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> 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..1085a15d17ff1 100644 --- a/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/MLProgram/Transforms/Passes.td @@ -11,7 +11,8 @@ 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 +22,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 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> createRemoveShapeConstraintsPass(); - -/// Outline the shape computation part by adding shape.func and populate -/// conrresponding mapping infomation into ShapeMappingAnalysis. -std::unique_ptr> createOutlineShapeComputationPass(); //===----------------------------------------------------------------------===// // Registration diff --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td index 83834509b4a35..588b5ebc5e37a 100644 --- a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td @@ -11,7 +11,8 @@ 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 +90,16 @@ def OutlineShapeComputation : Pass<"outline-shape-computation", "ModuleOp"> { // - Shape for: %1 = "test.concat"(%0, %arg1) {axis = 0 : i64} : (tensor, tensor<2x4x?xf32>) -> tensor :: @shape_cal_1( of type 'tensor' 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 { + : public impl::MLProgramPipelineGlobalsPassBase { public: void runOnOperation() override; @@ -224,10 +224,5 @@ void MLProgramPipelineGlobals::runOnOperation() { } // namespace -std::unique_ptr> -createMLProgramPipelineGlobalsPass() { - return std::make_unique(); -} - } // 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..ae06a34b65709 100644 --- a/mlir/lib/Dialect/Shape/Transforms/OutlineShapeComputation.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/OutlineShapeComputation.cpp @@ -23,7 +23,7 @@ #include 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,8 @@ void constructShapeFunc( } struct OutlineShapeComputationPass - : public impl::OutlineShapeComputationBase { + : public impl::OutlineShapeComputationPassBase< + OutlineShapeComputationPass> { void runOnOperation() override; @@ -324,8 +325,3 @@ bool OutlineShapeComputationPass::calOnlyUsedByWithShapesRecursively( } } // namespace - -std::unique_ptr> -mlir::createOutlineShapeComputationPass() { - return std::make_unique(); -} 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 { /// Removal pass. class RemoveShapeConstraintsPass - : public impl::RemoveShapeConstraintsBase { + : public impl::RemoveShapeConstraintsPassBase { void runOnOperation() override { MLIRContext &ctx = getContext(); @@ -65,8 +65,3 @@ void mlir::populateRemoveShapeConstraintsPatterns(RewritePatternSet &patterns) { patterns.add( patterns.getContext()); } - -std::unique_ptr> -mlir::createRemoveShapeConstraintsPass() { - return std::make_unique(); -} 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 { + : public impl::ShapeToShapeLoweringPassBase { void runOnOperation() override; }; } // namespace @@ -81,7 +81,3 @@ void ShapeToShapeLowering::runOnOperation() { void mlir::populateShapeRewritePatterns(RewritePatternSet &patterns) { patterns.add(patterns.getContext()); } - -std::unique_ptr mlir::createShapeToShapeLowering() { - return std::make_unique(); -}