Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PatternLang] Add a check for null function attributes #5674

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/relay/ir/dataflow_matcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool DFPatternMatcher::VisitDFPattern_(const AttrPatternNode* attr_pattern, cons
} else if (auto* op = expr.as<FunctionNode>()) {
matches = true;
for (auto kv : attributes) {
if (matches && op->attrs->dict.count(kv.first)) {
if (matches && op->attrs.defined() && op->attrs->dict.count(kv.first)) {
matches &= StructuralEqual()(kv.second, op->attrs->dict[kv.first]);
} else {
matches = false;
Expand Down Expand Up @@ -456,7 +456,7 @@ class PatternGrouper {
size_t index = i - 1;
Expr current = matcher_->expr_graph_.topological_order_.at(index)->ref_;
if (auto op = current.as<FunctionNode>()) {
if (op->attrs->dict.count(attr::kPartitionedFromPattern) != 0) {
if (op->attrs.defined() && op->attrs->dict.count(attr::kPartitionedFromPattern) != 0) {
pre_partitioned.insert(current);
PostOrderVisit(op->body,
[&pre_partitioned](const Expr& expr) { pre_partitioned.insert(expr); });
Expand Down