You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/01/27 21:43:22 UTC

[GitHub] [tvm] altanh commented on a change in pull request #10078: [Relay] fix incorrect binding of Lets in ANF conversion

altanh commented on a change in pull request #10078:
URL: https://github.com/apache/tvm/pull/10078#discussion_r794022288



##########
File path: src/relay/transforms/to_a_normal_form.cc
##########
@@ -223,6 +223,17 @@ class Fill : ExprFunctor<Expr(const Expr&, const Var&)>, private transform::Lexi
     bool not_included = include_set_ && include_set_->find(orig) == include_set_->end();
     if (!v.defined() && not_included) {
       return annotated_expr;
+    } else if (const LetNode* let = AsIgnoringOnDevice<LetNode>(now)) {
+      // Instead of making a nested binding "let var = (let x = ...; bindings...; body)", we push
+      // the inner bindings into the outer scope and bind body to var, giving
+      // "let x = ...; bindings...; let var = body;" as the resulting bindings.
+      Expr e = GetRef<Expr>(let);
+      while (const LetNode* inner_let = AsIgnoringOnDevice<LetNode>(e)) {
+        GetScope(orig)->let_list->Push(inner_let->var, inner_let->value);

Review comment:
       I *think* the inner values should already be wrapped, right? assuming they were already handled by a recursive `Compound` call




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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org