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



##########
File path: src/relay/transforms/type_infer.cc
##########
@@ -603,7 +611,21 @@ class TypeInferencer::Resolver : public MixedModeMutator, 
PatternMutator {
 
   Expr Rewrite_(const CallNode* op, const Expr& post) final { return 
AttachCheckedType(op, post); }
 
-  Expr VisitExpr_(const LetNode* op) final { return AttachCheckedType(op); }
+  Expr VisitExpr_(const LetNode* op) final {
+    auto pre_visit = [this](const LetNode* op) {
+      this->VisitExpr(op->var);
+      this->VisitExpr(op->value);
+    };
+    auto post_visit = [this](const LetNode* op) {
+      Expr expr = GetRef<Expr>(op);
+      Var var = Downcast<Var>(this->VisitExpr(op->var));
+      Expr value = this->VisitExpr(op->value);

Review comment:
       We just need to pull the values out of the cache. Instead of maintaining 
a cache shared by the two lambdas, I'm using the memorization cache in the 
Mutator. The second time visit is called, it will short circuit and return the 
previously computed value.




----------------------------------------------------------------
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