StrongerXi commented on code in PR #13343:
URL: https://github.com/apache/tvm/pull/13343#discussion_r1019722762
##########
src/relay/transforms/pattern_utils.h:
##########
@@ -120,6 +120,21 @@ inline Expr InferType(const Expr& expr) {
}
}
+/*!
+ * \brief Try to apply constant folding over expr:
+ *
+ * Do constant_fold over each node in expr
+ *
+ * \param expr The IR expression
+ * \return resulting expr
+ */
+inline Expr FoldConstantExpr(const Expr& expr) {
+ IRModule const_mod = IRModule::FromExpr(expr);
+ const_mod = transform::FoldConstant()(const_mod);
+ GlobalVar const_main = const_mod->GetGlobalVar("main");
+ return Downcast<Function>(const_mod->functions[const_main])->body;
+}
Review Comment:
I like that, done!
Also caught another duplication in `relay/quantize/realize.cc`. Let me know
if this PR needs more tweaking.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]