You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "akaashrp (via GitHub)" <gi...@apache.org> on 2026/08/16 05:05:34 UTC

[PR] [Fix][Relax] Preserve tensor-derived symbols during fusion [tvm]

akaashrp opened a new pull request, #20139:
URL: https://github.com/apache/tvm/pull/20139

   `FuseOps` may lift a symbolic primitive argument into an independent scalar parameter before the complete fused-function boundary is known. This can sever its relationship with tensor or shape types, making the result argument-order dependent and potentially producing an invalid or redundant ABI. This PR classifies symbolic primitive arguments after collecting the full fused-function boundary, preserving their relationship with tensor and shape types regardless of argument order.


-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [Fix][Relax] Preserve tensor-derived symbols during fusion [tvm]

Posted by "tlopex (via GitHub)" <gi...@apache.org>.
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [Fix][Relax] Preserve tensor-derived symbols during fusion [tvm]

Posted by "tlopex (via GitHub)" <gi...@apache.org>.
tlopex merged PR #20139:
URL: https://github.com/apache/tvm/pull/20139


-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [Fix][Relax] Preserve tensor-derived symbols during fusion [tvm]

Posted by "yongwww (via GitHub)" <gi...@apache.org>.
yongwww closed pull request #20139: [Fix][Relax] Preserve tensor-derived symbols during fusion
URL: https://github.com/apache/tvm/pull/20139


-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [Fix][Relax] Preserve tensor-derived symbols during fusion [tvm]

Posted by "akaashrp (via GitHub)" <gi...@apache.org>.
akaashrp commented on PR #20139:
URL: https://github.com/apache/tvm/pull/20139#issuecomment-5314721300

   @tvm-bot rerun


-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org