sunggg commented on code in PR #14146:
URL: https://github.com/apache/tvm/pull/14146#discussion_r1120355092


##########
python/tvm/relax/transform/legalize_ops/common.py:
##########
@@ -90,7 +90,7 @@ def _call_topi_without_attr(te_func: TEFunc, primfunc_name: 
Optional[str] = None
 _LEGALIZE_ATTR_NAME = "FLegalize"
 
 
-def register_legalize(op_name: str, legal_func: LegalizeFunc = None):
+def register_legalize(op_name: str, legal_func: LegalizeFunc = None, level: 
int = 10):

Review Comment:
   Is there any necessity for `level` in this PR? 
   Otherwise, I would prefer not introducing `level` yet and keep the legalizer 
dedicated to the reference implementation.  
   If we want to lower to different implementation depending on the context, we 
can introduce target-specialization pass. In this way, I believe we can make 
the lowering process composable. 
   



##########
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:
   Would this include whether this `expr` is eligible or not? 
   Or do we have a check before this heuristic and every `expr` at this point 
is eligible?



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

Reply via email to