zacharywhitley commented on issue #20064:
URL: https://github.com/apache/tvm/issues/20064#issuecomment-5111599325

   Author here. After trying to actually apply the suggested patch, I realized 
it doesn't work as written — apologies for the misleading sketch. Documenting 
what I found in case it saves someone else the trip:
   
   - `bb.emit_te(lambda t: t[()], x)` fails at emit time — the lambda returns a 
Python scalar, not a `te.tensor`, so it hits `"only support te.tensor or 
tuple/list/Array of te.tensor as function output"`.
   - Even with the lambda fixed to return a rank-0 `te.tensor`, `bb.emit_te` 
returns a `relax.Var`, not a `PrimExpr`. `relax.op.arange`'s signature is `int 
| PrimExpr | PrimValue`, so passing the Var reproduces the original 
type-mismatch error one hop later.
   - Fundamentally, a runtime tensor value can't be lifted into a compile-time 
`PrimExpr` — they live at different phases. The real fix needs either extending 
`relax.op.arange` to accept a rank-0 tensor for `limit` (with dynamic output 
shape) or introducing a `relax.op.dynamic_arange`. Both are substantive 
changes, not a 3-line patch.
   
   I worked around this at the ONNX-graph layer for my use case (fixed-length 
buckets: rewrite the offending `Range` to use a `Constant(max_frames)` for 
`limit`, downstream masking handles positions past the actual duration). 
Leaving the report open because the underlying issue is real — a large class of 
transformer ONNX exports hit this pattern — but the fix path is deeper than my 
initial patch sketch suggested.


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