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/11/10 03:31:12 UTC

[GitHub] [tvm] StrongerXi commented on a diff in pull request #13343: [Relay] Refactor constant folding over expr into a utility function

StrongerXi commented on code in PR #13343:
URL: https://github.com/apache/tvm/pull/13343#discussion_r1018619124


##########
src/relay/transforms/simplify_expr.cc:
##########
@@ -795,10 +795,7 @@ class SwitchAddMultiply : public DFPatternRewrite {
     }
 
     Expr const_expr = Call(Op::Get("multiply"), {c1, c2});
-    IRModule const_mod = IRModule::FromExpr(const_expr);
-    const_mod = transform::FoldConstant()(const_mod);
-    GlobalVar const_main = const_mod->GetGlobalVar("main");
-    Expr const_val = Downcast<Function>(const_mod->functions[const_main])->body;
+    Expr const_val = FoldConstantExpr(const_expr);

Review Comment:
   IMHO this keeps the transformation logic a lot cleaner, and allows future reuse.



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