Skip to content

Commit

Permalink
fix a bug with the Attr Pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookhart committed Feb 9, 2021
1 parent 076c3e2 commit 7693107
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/relay/ir/dataflow_matcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,12 @@ bool DFPatternMatcher::VisitDFPattern_(const AttrPatternNode* attr_pattern, cons
if (Op::HasAttrMap(attr_name)) {
auto op_map = Op::GetAttrMap<TVMRetValue>(attr_name);
if (op_map.count(op)) {
matches = MatchRetValue(attr_value, op_map[op]);
matches &= MatchRetValue(attr_value, op_map[op]);
} else {
matches = false;
}
} else {
matches = false;
}
}
} else if (auto* op = expr.as<CallNode>()) {
Expand Down Expand Up @@ -196,6 +200,8 @@ bool DFPatternMatcher::VisitDFPattern_(const AttrPatternNode* attr_pattern, cons
break;
}
}
} else {
matches = false;
}
return matches;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/python/relay/test_dataflow_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ def test_no_match_op_attr():
x = relay.var("x")
y = relay.var("y")
assert not op_pat.match(x - y)
z = relay.var("z")
assert not op_pat.match(relay.Let(z, x + y, z))


def test_match_func_attr():
Expand Down

0 comments on commit 7693107

Please sign in to comment.