[Mlir-commits] [mlir] [TOSA] Don't run validation pass on non TOSA operations (PR #120205)

Mehdi Amini llvmlistbot at llvm.org
Fri Dec 20 12:26:11 PST 2024


================
@@ -543,6 +543,10 @@ bool TosaValidation::isValidElementType(Type type) {
 void TosaValidation::runOnOperation() {
   configLevelAndProfile();
   getOperation().walk([&](Operation *op) {
+    if (!op->getDialect() ||
+        op->getDialect()->getNamespace() != TosaDialect::getDialectNamespace())
----------------
joker-eph wrote:

This isn't an efficient way to achieve this kind of comparison (and it's gonna be done on every operation in the IR). The best way to do is likely:

```
void TosaValidation::runOnOperation() {
   configLevelAndProfile();
   TosaDialect tosaDialect = getContext()->getLoadedDialect<TosaDialect>();
   if (!tosaDialect) return;
   
   getOperation().walk([&](Operation *op) {
     if (op->getDialect()  != tosaDialect)
```


https://github.com/llvm/llvm-project/pull/120205


More information about the Mlir-commits mailing list