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. |
…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.
f334dd8 to
e9d9243
Compare
|
Dropped the |
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. On
onnxruntime 1.23.2 for macOS arm64 the zero divisor raises nothing and returns the
dividend, which
Sliceclamps back into range so the result still looks correct; on the build in#3024 it fails with
Integer modulo by zero.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.