Skip to content

Commit

Permalink
add a check for null function attributes (apache#5674)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Brookhart authored and trevor-m committed Jun 18, 2020
1 parent 59f06b8 commit c43ecb5
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 c43ecb5

Please sign in to comment.