microsoft / microsoft/onnxruntime
Slice behavior wrong with negative step and end = INT_MAX
@hariharans29 is already working on this.
Since Apr 5, 2022.
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 179
Description
Describe the bug
ORT's Slice tests assert that Slice(x, starts = [-1], ends = [INT_MAX], steps = [-1]) == Reverse(x).
ONNX spec says:
For slicing to the end of a dimension with unknown size, it is recommended to pass in
INT_MAXwhen slicing forward andINT_MINwhen slicing backward.
I haven't yet tested to see if the behavior is correct with INT_MIN, but that should be checked as well.
Urgency
None.
To Reproduce
Build ORT and run onnxruntime_test_all --gtest_filter='SliceTest.Slice1D_ReverseAllAxes_1'.
Currently the test triggers a shape inference failure which results in a warning being logged.
Expected behavior
Slice(x, starts = [-1], ends = [INT_MAX], steps = [-1]) == <empty tensor>
Slice(x, starts = [-1], ends = [INT_MIN], steps = [-1]) == Reverse(x)
Both cases should be tested in ORT and not result in shape inference failures.
Additional context
Add any other context about the problem here. If the issue is about a particular model, please share the model details as well to facilitate debugging.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.