[Relax] Legalize shape_to_tensor to device kernel#19957
Conversation
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
ea19c4d to
f34ed21
Compare
tlopex
left a comment
There was a problem hiding this comment.
I just tested the symbolic case and it fails in the full build pipeline.
This legalization produces a call_tir with no tensor inputs and non-empty tir_vars, e.g. [m, n]. FoldConstant treats the empty tensor argument tuple as constant and attempts to execute the generated PrimFunc without
passing m and n, resulting in:
TypeError: Expected 3 arguments when calling:
tir_function(output, m, n)
A minimal reproducer is:
def main(x: R.Tensor(("m", "n"), "float32")):
return R.shape_to_tensor(R.shape_of(x))
relax.build(mod, target="cuda")
The current symbolic and mixed tests only run LegalizeOps, so they do not exercise this failure. Could we make FoldConstant skip call_tir calls with non-empty symbolic tir_vars (or otherwise handle those scalar arguments),
and add an end-to-end build test?
f34ed21 to
1a5a45d
Compare
1a5a45d to
39a1f1d
Compare
|
Thanks, reproduced exactly as described. The Fixed by bailing out when |
|
Thanks! |
Why
Fixes #19925.
relax.shape_to_tensorhad no legalization, so it always lowered to the host packed funcrelax.run.shape_to_tensor, producing a CPU tensor regardless of the target device.How
call_tirTE kernel, passing symbolic dims viatir_vars.ShapeStructInfowithout values).