Skip to content

Commit 8ae0ffb

Browse files
committed
Fix dialect check to avoid the cost of dialect lookup
1 parent 32a051d commit 8ae0ffb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ namespace {
4141
// When a non-replaceable use is encountered, the value is wrapped in a
4242
// cast back to the original type after inference.
4343
bool canBeRefined(Operation *user) {
44-
Dialect *tosaDialect = user->getContext()->getLoadedDialect<TosaDialect>();
45-
return user->getDialect() == tosaDialect ||
44+
if (!user->getDialect())
45+
return false;
46+
return user->getDialect()->getTypeID() == TypeID::get<TosaDialect>() ||
4647
isa<InferTypeOpInterface, InferShapedTypeOpInterface>(user);
4748
}
4849

0 commit comments

Comments
 (0)