tlopex commented on code in PR #20139:
URL: https://github.com/apache/tvm/pull/20139#discussion_r3858602838


##########
src/relax/transform/fuse_ops.cc:
##########
@@ -679,10 +679,38 @@ class FunctionCreator : public ExprMutator {
     if (const auto* tuple = expr.as<TupleNode>()) {
       return std::all_of(tuple->fields.begin(), tuple->fields.end(),
                          [this](const Expr& e) { return 
IsInlinableConstants(e); });
+    } else if (auto prim_value = expr.as<PrimExpr>()) {
+      ffi::Array<tirx::Var> undefined_vars = 
tvm::tirx::UndefinedVars(prim_value.value());

Review Comment:
   `PrimExpr` can also match a Relax `CallNode` returning `PrimType`. This may 
inline and duplicate calls such as `R.call_packed` inside the fused function. 
Could we exclude `CallNode` before this branch?



##########
src/relax/transform/fuse_ops.cc:
##########
@@ -679,10 +679,38 @@ class FunctionCreator : public ExprMutator {
     if (const auto* tuple = expr.as<TupleNode>()) {
       return std::all_of(tuple->fields.begin(), tuple->fields.end(),
                          [this](const Expr& e) { return 
IsInlinableConstants(e); });
+    } else if (auto prim_value = expr.as<PrimExpr>()) {
+      ffi::Array<tirx::Var> undefined_vars = 
tvm::tirx::UndefinedVars(prim_value.value());
+      if (undefined_vars.empty()) {
+        return true;
+      }
+
+      // A symbolic value directly defined by an existing tensor/shape 
parameter is already part
+      // of the grouped function's shape environment.  A variable that only 
occurs inside a
+      // derived dimension is not directly definable, but leaving it symbolic 
lets CreateFunction
+      // add the explicit Shape parameter required to define it.  In either 
case, lifting the value
+      // as an unrelated scalar parameter would sever the relation to the 
parameter types.
+      auto parameter_types =
+          TupleType(params_.Map([](const Var& param) { return GetType(param); 
}));

Review Comment:
   `params_` only contains previously visited arguments here, so this is still 
order-dependent. `(x, n)` works, but `(n, x)` still lifts `n` separately. Could 
this classification be deferred until the full boundary is collected?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to