[Mlir-commits] [mlir] [TOSA] Handle dialect check more efficiently (PR #120960)

Luke Hutton llvmlistbot at llvm.org
Mon Dec 23 04:07:58 PST 2024


https://github.com/lhutton1 updated https://github.com/llvm/llvm-project/pull/120960

>From 185f7750af51f00b877c08ccec28b8d5dc1c5699 Mon Sep 17 00:00:00 2001
From: Luke Hutton <luke.hutton at arm.com>
Date: Fri, 20 Dec 2024 21:18:13 +0000
Subject: [PATCH] [TOSA] Handle dialect check more efficiently

After a suggestion in #120205, this commit adjusts a dialect check
that runs per op to be more efficient.

Signed-off-by: Luke Hutton <luke.hutton at arm.com>
Change-Id: I137ec8e1fd73dc2de0b211e1ff38cb128e99a671
---
 mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
index 6fd671051362ca..8588c878bfe4f8 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()) {



More information about the Mlir-commits mailing list