Lunderberg commented on issue #17247:
URL: https://github.com/apache/tvm/issues/17247#issuecomment-2273595100

   The introduction of `nan` is a bug in `RemoveUnusedOutputs`.  When 
determining which outputs of a callee are used, it only collected usages in 
`TupleGetItem(out_tuple, index)`.  If the tuple is used in a context that 
doesn't access a specific element, such as returning from a function, then the 
usage is skipped.
   
   The `nan` values are intended as placeholders, as a dummy value for 
indexing.  If a callee produces `(A,B,C)`, but `B` is never used, then the 
callee would be updated to produce `(A,C)`, and callsites would be updated to 
replace `res = callee()` with `new_output = callee(); res = (new_output[0], 
NaN, new_output[1])`.  The intermediate tuple would then be deconstructed with 
`CanonicalizeBindings`.  Since nothing ever accessed `res[1]`, the `NaN` value 
at that location would drop out altogether.
   
   So, if a function called a subroutine that produces a tuple, then 
immediately returned that tuple, the usage would fail to be collected, and the 
tuple elements would be erroneously replaced with `NaN`.  This should be 
resolved with https://github.com/apache/tvm/pull/17253.


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