Skip to content

Commit 08f91b9

Browse files
committed
[BugFix][Relay] skip leaf args when matching 'path' part for dominator pattern
1 parent c0a47ed commit 08f91b9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/relay/ir/dataflow_matcher.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,17 @@ bool DFPatternMatcher::VisitDFPattern_(const CallPatternNode* op, const Expr& ex
300300

301301
// Recursively find the Dominator parent along all inputs paths.
302302
bool DFPatternMatcher::MatchesPath(const DominatorPatternNode* op, const Expr& expr) {
303+
// utilities
304+
auto is_leaf_node = [](const Expr& expr) {
305+
return expr.as<ConstantNode>() || expr.as<VarNode>();
306+
};
307+
308+
// logic
303309
auto call_node = expr.as<CallNode>();
304310
auto index_node = expr_to_node(expr);
305311
size_t arg_counter{0};
306312
for (auto node : index_node->inputs_) {
307-
if (!(call_node && node->ref() == call_node->op)) {
313+
if (!(call_node && (node->ref() == call_node->op || is_leaf_node(node->ref())))) {
308314
arg_counter += 1;
309315
memoize_ = true;
310316
if (!VisitDFPattern(op->parent, node->ref())) {

0 commit comments

Comments
 (0)