mbrookhart commented on a change in pull request #7588:
URL: https://github.com/apache/tvm/pull/7588#discussion_r587641059



##########
File path: src/relay/ir/expr_functor.cc
##########
@@ -103,11 +103,39 @@ Expr MixedModeMutator::VisitExpr(const Expr& expr) {
 class PostOrderRewriter : public MixedModeMutator {
  public:
   explicit PostOrderRewriter(ExprRewriter* rewriter) : rewriter_(rewriter) {}
+
   Expr DispatchVisitExpr(const Expr& expr) final {
     auto post = ExprFunctor::VisitExpr(expr);
     return rewriter_->Rewrite(expr, post);
   }
 
+  Expr VisitExpr_(const LetNode* op) final {
+    auto pre_visit = [this](const LetNode* op) {
+      Expr var = this->Mutate(op->var);
+      Expr value = this->Mutate(op->value);
+    };
+    auto post_visit = [this](const LetNode* op) {
+      Var var = Downcast<Var>(this->memo_[op->var]);
+      Expr value = this->memo_[op->value];
+      Expr body;
+      if (this->memo_.count(op->body)) {

Review comment:
       Nitpick: `this->Mutate` already does the memo check, you don't need to 
do it manually here. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to