[Relax] Avoid wrapping TupleStructInfo into a Tuple for R.call_tir #17243
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this commit, the different
R.call_tir*
variations would wrap the arguments into an in-linerelax.Tuple
, if it is not already arelax.Tuple
. While this allows a tensor to be passed into these functions as a single argument (R.call_tir(func, arg, ...)
instead ofR.call_tir(func, [arg], ...)
), the wrapped Relax variable may already refer to a tuple.This use of a variable to refer to an argument tuple rather than an in-line argument tuple is not allowed by Relax. (See discussion on #15916 for details.) However, by wrapping a variable
args: R.Tuple(R.Tensor, R.Tensor, ...)
into a tuple-of-tuples, the error occurs after the expression has already been generated, and refers to an expressionR.Tuple(R.Tuple(R.Tensor, R.Tensor, ...))
that doesn't appear anywhere in the user's input. This can make debugging difficult (see #17239 for an example).This commit updates the argument-handling in
R.call_tir
to only generate an in-linerelax.Tuple
if the arguments do not already haverelax.TupleStructInfo
. If the argument was provided as a Relax variable bound to a tuple of arguments, it will still produce an error. However, that error will occur much earlier, and will explicitly state that the argument must be arelax.Tuple
instead of arelax.Var
.