-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][NFC] Retire let constructor for Tosa #134784
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-mlir-tosa @llvm/pr-subscribers-mlir Author: lorenzo chelini (chelini) Changes
Full diff: https://github.com/llvm/llvm-project/pull/134784.diff 7 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.h b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.h
index 33bbc069c521d..306e4b1f218e7 100644
--- a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.h
@@ -41,13 +41,7 @@ void populateTosaConstantReduction(MLIRContext *ctx,
void populateTosaTypeConversion(TypeConverter &converter);
-std::unique_ptr<Pass> createTosaLayerwiseConstantFoldPass();
-std::unique_ptr<Pass> createTosaLayerwiseConstantFoldPass(
- const TosaLayerwiseConstantFoldPassOptions &options);
-std::unique_ptr<Pass> createTosaInferShapesPass();
-std::unique_ptr<Pass> createTosaMakeBroadcastablePass();
std::unique_ptr<Pass> createTosaTestQuantUtilAPIPass();
-std::unique_ptr<Pass> createTosaOptionalDecompositions();
#define GEN_PASS_REGISTRATION
#include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
diff --git a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td
index 2d5b0b39df078..d005a4cc6859c 100644
--- a/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/Tosa/Transforms/Passes.td
@@ -22,8 +22,6 @@ def TosaLayerwiseConstantFoldPass : Pass<"tosa-layerwise-constant-fold", "func::
Pass that enables folding of full-layer operations on constant tensors.
}];
- let constructor = "createTosaLayerwiseConstantFoldPass()";
-
let options = [
Option<"aggressiveReduceConstant", "aggressive-reduce-constant", "bool",
/*default=*/"false",
@@ -32,14 +30,13 @@ def TosaLayerwiseConstantFoldPass : Pass<"tosa-layerwise-constant-fold", "func::
];
}
-def TosaInferShapes : Pass<"tosa-infer-shapes", "func::FuncOp"> {
+def TosaInferShapesPass : Pass<"tosa-infer-shapes", "func::FuncOp"> {
let summary = "Propagate shapes across TOSA operations";
let description = [{
Pass that uses operand types and propagates shapes to TOSA operations.
This includes legalizing rankless and dynamic shapes towards static.
}];
- let constructor = "createTosaInferShapesPass()";
let dependentDialects = [
"func::FuncDialect",
"tensor::TensorDialect",
@@ -47,7 +44,8 @@ def TosaInferShapes : Pass<"tosa-infer-shapes", "func::FuncOp"> {
];
}
-def TosaMakeBroadcastable : Pass<"tosa-make-broadcastable", "func::FuncOp"> {
+def TosaMakeBroadcastablePass
+ : Pass<"tosa-make-broadcastable", "func::FuncOp"> {
let summary = "TOSA rank Reshape to enable Broadcasting";
let description = [{
Pass that enables broadcast by making all input arrays have the same
@@ -56,19 +54,15 @@ def TosaMakeBroadcastable : Pass<"tosa-make-broadcastable", "func::FuncOp"> {
approach similar to step 1 of Numpy 4-step broadcasting:
https://numpy.org/doc/stable/reference/ufuncs.html#broadcasting
}];
-
- let constructor = "createTosaMakeBroadcastablePass()";
}
-def TosaOptionalDecompositions
- : Pass<"tosa-optional-decompositions", "func::FuncOp"> {
+def TosaOptionalDecompositionsPass
+ : Pass<"tosa-optional-decompositions", "func::FuncOp"> {
let summary = "Applies Tosa operations optional decompositions";
let description = [{
Pass to apply the Tosa operations decompositions
exposed as populate functions in include/mlir/Dialect/Tosa/Transforms/Passes.h
}];
-
- let constructor = "tosa::createTosaOptionalDecompositions()";
}
def TosaLevelType : I32EnumAttr<"TosaLevelEnum", "Tosa level",
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp
index 4cf232a7bc767..01a7cd7ac94db 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp
@@ -85,7 +85,8 @@ void mlir::tosa::addTosaToLinalgPasses(
std::optional<tosa::TosaValidationOptions> validationOptions) {
// Optional decompositions are designed to benefit linalg.
if (!options.disableTosaDecompositions)
- pm.addNestedPass<func::FuncOp>(tosa::createTosaOptionalDecompositions());
+ pm.addNestedPass<func::FuncOp>(
+ tosa::createTosaOptionalDecompositionsPass());
pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());
pm.addNestedPass<func::FuncOp>(tosa::createTosaInferShapesPass());
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp
index 0d4ea9710d723..9aa0051070bd6 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp
@@ -25,7 +25,7 @@
namespace mlir {
namespace tosa {
-#define GEN_PASS_DEF_TOSAINFERSHAPES
+#define GEN_PASS_DEF_TOSAINFERSHAPESPASS
#include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
} // namespace tosa
} // namespace mlir
@@ -333,7 +333,7 @@ void validateSameOperandsAndResultRankTrait(Region ®ion) {
/// Pass that performs shape propagation across TOSA operations. This includes
/// migrating to within the regions of if/while operations.
struct TosaInferShapes
- : public tosa::impl::TosaInferShapesBase<TosaInferShapes> {
+ : public tosa::impl::TosaInferShapesPassBase<TosaInferShapes> {
public:
void runOnOperation() override {
func::FuncOp func = getOperation();
@@ -344,8 +344,4 @@ struct TosaInferShapes
validateSameOperandsAndResultRankTrait(func.getBody());
}
};
-} // namespace
-
-std::unique_ptr<Pass> mlir::tosa::createTosaInferShapesPass() {
- return std::make_unique<TosaInferShapes>();
-}
+} // namespace
\ No newline at end of file
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaLayerwiseConstantFoldPass.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaLayerwiseConstantFoldPass.cpp
index 9299db7e51a01..f4ce950828646 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaLayerwiseConstantFoldPass.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaLayerwiseConstantFoldPass.cpp
@@ -45,9 +45,7 @@ void populateTosaOpsCanonicalizationPatterns(MLIRContext *ctx,
struct TosaLayerwiseConstantFoldPass
: public tosa::impl::TosaLayerwiseConstantFoldPassBase<
TosaLayerwiseConstantFoldPass> {
- TosaLayerwiseConstantFoldPass(
- const TosaLayerwiseConstantFoldPassOptions &options)
- : TosaLayerwiseConstantFoldPassBase(options) {}
+ using Base::Base;
void runOnOperation() override {
auto *ctx = &getContext();
@@ -66,13 +64,3 @@ struct TosaLayerwiseConstantFoldPass
};
} // namespace
-
-std::unique_ptr<Pass> mlir::tosa::createTosaLayerwiseConstantFoldPass() {
- return std::make_unique<TosaLayerwiseConstantFoldPass>(
- TosaLayerwiseConstantFoldPassOptions{false});
-}
-
-std::unique_ptr<Pass> mlir::tosa::createTosaLayerwiseConstantFoldPass(
- const TosaLayerwiseConstantFoldPassOptions &options) {
- return std::make_unique<TosaLayerwiseConstantFoldPass>(options);
-}
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
index 87b2a2695351b..02a3ad83bdefa 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
@@ -21,7 +21,7 @@
namespace mlir {
namespace tosa {
-#define GEN_PASS_DEF_TOSAMAKEBROADCASTABLE
+#define GEN_PASS_DEF_TOSAMAKEBROADCASTABLEPASS
#include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
} // namespace tosa
} // namespace mlir
@@ -219,7 +219,7 @@ namespace {
/// Pass that enables broadcast by making all input arrays have the same
/// number of dimensions. Insert RESHAPE operations to lower rank operand
struct TosaMakeBroadcastable
- : public tosa::impl::TosaMakeBroadcastableBase<TosaMakeBroadcastable> {
+ : public tosa::impl::TosaMakeBroadcastablePassBase<TosaMakeBroadcastable> {
public:
void runOnOperation() override {
auto func = getOperation();
@@ -250,7 +250,3 @@ struct TosaMakeBroadcastable
}
};
} // namespace
-
-std::unique_ptr<Pass> mlir::tosa::createTosaMakeBroadcastablePass() {
- return std::make_unique<TosaMakeBroadcastable>();
-}
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp
index ffa2ea3d0629f..2092379e65368 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp
@@ -21,7 +21,7 @@
namespace mlir {
namespace tosa {
-#define GEN_PASS_DEF_TOSAOPTIONALDECOMPOSITIONS
+#define GEN_PASS_DEF_TOSAOPTIONALDECOMPOSITIONSPASS
#include "mlir/Dialect/Tosa/Transforms/Passes.h.inc"
} // namespace tosa
} // namespace mlir
@@ -31,7 +31,7 @@ using namespace mlir;
namespace {
struct TosaOptionalDecompositions
- : public tosa::impl::TosaOptionalDecompositionsBase<
+ : public tosa::impl::TosaOptionalDecompositionsPassBase<
TosaOptionalDecompositions> {
void runOnOperation() override {
auto *ctx = &getContext();
@@ -47,7 +47,3 @@ struct TosaOptionalDecompositions
};
} // namespace
-
-std::unique_ptr<Pass> mlir::tosa::createTosaOptionalDecompositions() {
- return std::make_unique<TosaOptionalDecompositions>();
-}
|
joker-eph
approved these changes
Apr 8, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
let constructor
is legacy (do not use in tree!) since the tableGenbackend emits most of the glue logic to build a pass.