psrivas2 commented on code in PR #14146:
URL: https://github.com/apache/tvm/pull/14146#discussion_r1120574529
##########
src/relax/transform/fold_constant.cc:
##########
@@ -127,6 +129,19 @@ class ConstantFolder : public ExprMutator {
return build_func;
}
+ /*!
+ * \brief Checks if it is useful to fold \p expr.
+ * \details Folding an expr is a trade-off - we are materializing a constant
in the IRModule and
+ * paying compile time cost to avoid the cost of executing this expr at
runtime. For example,
+ * folding iota ops could result in large constants being materialized, thus
increasing the size
+ * of the program.
+ */
+ bool ShouldBeFolded(Expr expr) {
+ // TODO(prakalp): Implement a heuristic to check if folding this op is
actually useful or
Review Comment:
This would not check if the expression is eligible, but it need not check
that too. It would probably only need to check expr input and output shapes and
decide if the folding would be useful.
Another place to do this could be post matching call_tir and figured out its
constant input args. We could then pass input/output shapes to figure out if
folding would be useful.
--
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]