Skip to content

Commit

Permalink
dicrease the complexity of CalcDep from exponential to linear
Browse files Browse the repository at this point in the history
  • Loading branch information
yaochengji committed Oct 3, 2019
1 parent 7d911f4 commit f75253c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/relay/pass/dead_code.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ class CalcDep : private ExprVisitor {
VarMap<size_t> use_map_;

void VisitExpr(const Expr& e) final {
return ExprFunctor<void(const Expr& e)>::VisitExpr(e);
visit_counter_[e.get()]++;
if (visit_counter_[e.get()] <= 2) {
using TParent = ExprFunctor<void(const Expr&)>;
TParent::VisitExpr(e);
}
}

void VisitExpr_(const LetNode* l) final {
Expand Down

0 comments on commit f75253c

Please sign in to comment.