From c43ecb56f5de7a3177c64d6cd6d547f0918640f5 Mon Sep 17 00:00:00 2001 From: Matthew Brookhart Date: Tue, 26 May 2020 13:16:13 -0700 Subject: [PATCH] add a check for null function attributes (#5674) --- src/relay/ir/dataflow_matcher.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/relay/ir/dataflow_matcher.cc b/src/relay/ir/dataflow_matcher.cc index dd9d80648d90..409dbc339c65 100644 --- a/src/relay/ir/dataflow_matcher.cc +++ b/src/relay/ir/dataflow_matcher.cc @@ -158,7 +158,7 @@ bool DFPatternMatcher::VisitDFPattern_(const AttrPatternNode* attr_pattern, cons } else if (auto* op = expr.as()) { 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; @@ -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()) { - 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); });