-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[TOSA] Handle dialect check more efficiently #120960
Conversation
@llvm/pr-subscribers-mlir Author: Luke Hutton (lhutton1) ChangesAfter a suggestion in #120205, this commit adjusts a dialect check that runs per op to be more efficient. Full diff: https://github.com/llvm/llvm-project/pull/120960.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
index 6fd671051362ca..c58f8927217940 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
@@ -542,9 +542,13 @@ bool TosaValidation::isValidElementType(Type type) {
void TosaValidation::runOnOperation() {
configLevelAndProfile();
+
+ TosaDialect* tosaDialect = getContext().getLoadedDialect<TosaDialect>();
+ if (!tosaDialect)
+ return;
+
getOperation().walk([&](Operation *op) {
- if (!op->getDialect() ||
- op->getDialect()->getNamespace() != TosaDialect::getDialectNamespace())
+ if (op->getDialect() != tosaDialect)
return;
for (Value operand : op->getOperands()) {
|
@llvm/pr-subscribers-mlir-tosa Author: Luke Hutton (lhutton1) ChangesAfter a suggestion in #120205, this commit adjusts a dialect check that runs per op to be more efficient. Full diff: https://github.com/llvm/llvm-project/pull/120960.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
index 6fd671051362ca..c58f8927217940 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
@@ -542,9 +542,13 @@ bool TosaValidation::isValidElementType(Type type) {
void TosaValidation::runOnOperation() {
configLevelAndProfile();
+
+ TosaDialect* tosaDialect = getContext().getLoadedDialect<TosaDialect>();
+ if (!tosaDialect)
+ return;
+
getOperation().walk([&](Operation *op) {
- if (!op->getDialect() ||
- op->getDialect()->getNamespace() != TosaDialect::getDialectNamespace())
+ if (op->getDialect() != tosaDialect)
return;
for (Value operand : op->getOperands()) {
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
After a suggestion in llvm#120205, this commit adjusts a dialect check that runs per op to be more efficient. Signed-off-by: Luke Hutton <luke.hutton@arm.com> Change-Id: I137ec8e1fd73dc2de0b211e1ff38cb128e99a671
cee2f4a
to
185f775
Compare
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.
LGTM, thanks!
Local branch amd-gfx d1314f0 Merged main:998bdae7f5ce into amd-gfx:1f2edbe54368 Remote branch main 39e93ee [TOSA] Handle dialect check more efficiently (llvm#120960)
After a suggestion in #120205, this commit adjusts a dialect check that runs per op to be more efficient.