Skip to content

Commit

Permalink
add a check for null function attributes (#5674)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Brookhart authored May 26, 2020
1 parent b716a97 commit 6100112
Showing 1 changed file with 2 additions and 2 deletions.
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

0 comments on commit 6100112

Please sign in to comment.