[Relax][Frontend][ONNX] Support dynamic Range bounds - #20109
Conversation
tlopex
left a comment
There was a problem hiding this comment.
Overall the approach looks good, but I think there are a few cases we should fix before merging. The main one is that the dynamic float32 path computes the range length in float32, so something like Range(0, 0.3, 0.1) produces 3 elements while ONNX Runtime produces 4. Also, mixed runtime tensor and PrimExpr bounds can fail because scalar_expr passes the PrimExpr to relax.op.astype, and the PrimExpr-only path still relies on relax.arange, whose shape inference is incorrect for negative steps or empty ranges. Could we handle PrimExpr explicitly, use higher precision for the float count, and add tests for these cases?
266b77d to
f5f43f1
Compare
|
I have updated the lowering to handle these cases before the Tests are added for |
Fixes #20064.
This updates ONNX
Rangelowering to support runtime scalar bounds, following the same strategy used by Relax TFLite dynamic RANGE lowering. The strategy is to compute the output length in graph, lift it to a symbolic dimension, and rebuild the range asarange(0, length) * delta + start.The existing constant path is preserved, and symbolic
PrimExprbounds continue to userelax.op.arangedirectly. Tests are added for constantRange, parametrized dynamic scalarRangeinputs, and symbolicPrimExprlimit.