Document that roll leaves a dynamic zero length dimension undefined - #3030
Document that roll leaves a dynamic zero length dimension undefined#3030om singhal (Om-singhaI) wants to merge 1 commit into
Conversation
|
Hopefully this doesn't over complicate the implementation? It is also possible to assume input will never be zero sized, I hope? |
|
It is small: one On assuming nonzero, I would rather not. It is a rare shape though. If you would rather not carry the guard at all I am happy to close this. One middle option if the cost is what bothers you: only emit the |
|
Thanks. I suggest we note the limitation clearly in the source, and then keep the status quo until someone actually needs the behavior. For onnxruntime, it would be great if you can update the different paths to all produce an error. |
f334dd8 to
e9d9243
Compare
|
Dropped the I'll look at the onnxruntime paths separately, though I'd rather not put a date on it. |
…undefined I dropped the Max guard on the modulo divisor and left the behavior as it is. The limitation is now written at both roll helpers: the export time check does not cover a dynamic dimension that is zero at run time, ONNX leaves that modulo undefined, and onnxruntime differs by build.
e9d9243 to
776efca
Compare
|
Correcting myself. The CPU kernel already errors on an integer divisor of zero, microsoft/onnxruntime#27833 added that and it shipped in 1.25.0. I'm on 1.23.2, so what I measured was a version gap, not a platform one. I've reworded the note in both helpers. CUDA is still unguarded though. I can't build onnxruntime to fix that, no NVIDIA hardware, and their guidelines want a build and a test run first. Happy to file an issue with the file and line if that's useful. |
torch.rollexported with a dimension that can be zero still reachesModwith azero divisor when that dimension is zero at run time. The
0 in self.shapeearlyreturn added in #3024 only covers a length known to be zero at export time, and ONNX
leaves modulo by zero undefined.
Undefined does not always mean loud, which is why it is worth writing down. The
onnxruntime CPU kernel has rejected an integer divisor of zero since microsoft/onnxruntime#27833
shipped in 1.25.0, but its CUDA kernel has no such check, and on 1.23.2 the zero divisor
raised nothing and returned the dividend, which
Sliceclamped back into range so theresult still looked correct.
This is a comment only change. The behavior is deliberately unchanged and the two
asserts stay as they are; each now carries the limitation next to it, and the early
return in
aten_rollno longer reads as though it covers the dynamic case.