-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Fix Shape operator specification: correct range bounds and document start > end behavior #7132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: justinchuby <[email protected]>
…tart > end behavior Co-authored-by: justinchuby <[email protected]>
Copilot
AI
changed the title
[WIP]
Fix Shape operator specification: correct range bounds and document start > end behavior
Jul 16, 2025
Shape spec issue with start and end bound clamping
Copilot finished work on behalf of
justinchuby
July 16, 2025 17:25
Signed-off-by: Justin Chu <[email protected]>
justinchuby
approved these changes
Jul 16, 2025
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #7132 +/- ##
==========================================
+ Coverage 53.70% 53.75% +0.04%
==========================================
Files 508 508
Lines 32097 32098 +1
Branches 2969 2969
==========================================
+ Hits 17238 17254 +16
+ Misses 14061 14048 -13
+ Partials 798 796 -2 ☔ View full report in Codecov by Sentry. |
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
justinchuby
approved these changes
Jul 16, 2025
gramalingam
approved these changes
Jul 16, 2025
lfopensource
pushed a commit
to lfopensource/onnx
that referenced
this pull request
Jul 22, 2025
…tart > end behavior (onnx#7132) The Shape operator specification incorrectly stated that axes are clamped to the range `[0, r-1]`, but since the `end` parameter is exclusive in slicing operations, the correct range should be `[0, r]`. Additionally, the spec was missing documentation for the `start > end` case. ## Changes Made ### Documentation Fixes - **Corrected range specification**: Changed from `[0, r-1]` to `[0, r]` in all Shape operator documentation - **Added start > end behavior**: Added "If start > end, the result will be an empty shape." to clarify edge case behavior ### Affected Versions Updated documentation for all Shape operator versions that support `start` and `end` attributes: - `Shape_ver24_doc` (current version) - `Shape_ver23_doc` - `Shape_ver19_doc` - `Shape_ver15_doc` Note: Older versions (ver13, ver1) don't have `start`/`end` attributes so no changes were needed. ### Test Coverage - Added test case `test_shape("_start_greater_than_end", x, start=2, end=1)` to validate the documented behavior - Verified that the reference implementation correctly returns an empty array when `start > end` ## Implementation Verification The underlying C++ implementation was already correct - it properly clamps both `start` and `end` to `[0, rank]` and handles the `start > end` case by returning an empty shape: ```cpp start = (start < 0) ? 0 : (start > rank) ? rank : start; end = (end < 0) ? 0 : (end > rank) ? rank : end; output_length->set_dim_value((end - start) < 0 ? 0 : (end - start)); ``` This fix ensures the documentation accurately reflects the actual behavior, making it consistent with how ONNX Runtime handles these edge cases. Fixes onnx#6862. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey. --------- Signed-off-by: Justin Chu <[email protected]> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: justinchuby <[email protected]> Co-authored-by: Justin Chu <[email protected]> Signed-off-by: lfopensource <[email protected]>
lfopensource
added a commit
to lfopensource/onnx
that referenced
this pull request
Jul 23, 2025
…tart > end behavior (onnx#7132) The Shape operator specification incorrectly stated that axes are clamped to the range `[0, r-1]`, but since the `end` parameter is exclusive in slicing operations, the correct range should be `[0, r]`. Additionally, the spec was missing documentation for the `start > end` case. ## Changes Made ### Documentation Fixes - **Corrected range specification**: Changed from `[0, r-1]` to `[0, r]` in all Shape operator documentation - **Added start > end behavior**: Added "If start > end, the result will be an empty shape." to clarify edge case behavior ### Affected Versions Updated documentation for all Shape operator versions that support `start` and `end` attributes: - `Shape_ver24_doc` (current version) - `Shape_ver23_doc` - `Shape_ver19_doc` - `Shape_ver15_doc` Note: Older versions (ver13, ver1) don't have `start`/`end` attributes so no changes were needed. ### Test Coverage - Added test case `test_shape("_start_greater_than_end", x, start=2, end=1)` to validate the documented behavior - Verified that the reference implementation correctly returns an empty array when `start > end` ## Implementation Verification The underlying C++ implementation was already correct - it properly clamps both `start` and `end` to `[0, rank]` and handles the `start > end` case by returning an empty shape: ```cpp start = (start < 0) ? 0 : (start > rank) ? rank : start; end = (end < 0) ? 0 : (end > rank) ? rank : end; output_length->set_dim_value((end - start) < 0 ? 0 : (end - start)); ``` This fix ensures the documentation accurately reflects the actual behavior, making it consistent with how ONNX Runtime handles these edge cases. Fixes onnx#6862. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey. --------- Signed-off-by: Justin Chu <[email protected]> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: justinchuby <[email protected]> Co-authored-by: Justin Chu <[email protected]> Signed-off-by: lfopensource <[email protected]>
lfopensource
added a commit
to lfopensource/onnx
that referenced
this pull request
Jul 23, 2025
…tart > end behavior (onnx#7132) The Shape operator specification incorrectly stated that axes are clamped to the range `[0, r-1]`, but since the `end` parameter is exclusive in slicing operations, the correct range should be `[0, r]`. Additionally, the spec was missing documentation for the `start > end` case. ## Changes Made ### Documentation Fixes - **Corrected range specification**: Changed from `[0, r-1]` to `[0, r]` in all Shape operator documentation - **Added start > end behavior**: Added "If start > end, the result will be an empty shape." to clarify edge case behavior ### Affected Versions Updated documentation for all Shape operator versions that support `start` and `end` attributes: - `Shape_ver24_doc` (current version) - `Shape_ver23_doc` - `Shape_ver19_doc` - `Shape_ver15_doc` Note: Older versions (ver13, ver1) don't have `start`/`end` attributes so no changes were needed. ### Test Coverage - Added test case `test_shape("_start_greater_than_end", x, start=2, end=1)` to validate the documented behavior - Verified that the reference implementation correctly returns an empty array when `start > end` ## Implementation Verification The underlying C++ implementation was already correct - it properly clamps both `start` and `end` to `[0, rank]` and handles the `start > end` case by returning an empty shape: ```cpp start = (start < 0) ? 0 : (start > rank) ? rank : start; end = (end < 0) ? 0 : (end > rank) ? rank : end; output_length->set_dim_value((end - start) < 0 ? 0 : (end - start)); ``` This fix ensures the documentation accurately reflects the actual behavior, making it consistent with how ONNX Runtime handles these edge cases. Fixes onnx#6862. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey. --------- Signed-off-by: Justin Chu <[email protected]> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: justinchuby <[email protected]> Co-authored-by: Justin Chu <[email protected]> Signed-off-by: lfopensource <[email protected]>
MagellaX
pushed a commit
to MagellaX/onnx
that referenced
this pull request
Aug 9, 2025
…tart > end behavior (onnx#7132) The Shape operator specification incorrectly stated that axes are clamped to the range `[0, r-1]`, but since the `end` parameter is exclusive in slicing operations, the correct range should be `[0, r]`. Additionally, the spec was missing documentation for the `start > end` case. ## Changes Made ### Documentation Fixes - **Corrected range specification**: Changed from `[0, r-1]` to `[0, r]` in all Shape operator documentation - **Added start > end behavior**: Added "If start > end, the result will be an empty shape." to clarify edge case behavior ### Affected Versions Updated documentation for all Shape operator versions that support `start` and `end` attributes: - `Shape_ver24_doc` (current version) - `Shape_ver23_doc` - `Shape_ver19_doc` - `Shape_ver15_doc` Note: Older versions (ver13, ver1) don't have `start`/`end` attributes so no changes were needed. ### Test Coverage - Added test case `test_shape("_start_greater_than_end", x, start=2, end=1)` to validate the documented behavior - Verified that the reference implementation correctly returns an empty array when `start > end` ## Implementation Verification The underlying C++ implementation was already correct - it properly clamps both `start` and `end` to `[0, rank]` and handles the `start > end` case by returning an empty shape: ```cpp start = (start < 0) ? 0 : (start > rank) ? rank : start; end = (end < 0) ? 0 : (end > rank) ? rank : end; output_length->set_dim_value((end - start) < 0 ? 0 : (end - start)); ``` This fix ensures the documentation accurately reflects the actual behavior, making it consistent with how ONNX Runtime handles these edge cases. Fixes onnx#6862. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey. --------- Signed-off-by: Justin Chu <[email protected]> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: justinchuby <[email protected]> Co-authored-by: Justin Chu <[email protected]> Signed-off-by: Yash solanki <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Shape operator specification incorrectly stated that axes are clamped to the range
[0, r-1], but since theendparameter is exclusive in slicing operations, the correct range should be[0, r]. Additionally, the spec was missing documentation for thestart > endcase.Changes Made
Documentation Fixes
[0, r-1]to[0, r]in all Shape operator documentationAffected Versions
Updated documentation for all Shape operator versions that support
startandendattributes:Shape_ver24_doc(current version)Shape_ver23_docShape_ver19_docShape_ver15_docNote: Older versions (ver13, ver1) don't have
start/endattributes so no changes were needed.Test Coverage
test_shape("_start_greater_than_end", x, start=2, end=1)to validate the documented behaviorstart > endImplementation Verification
The underlying C++ implementation was already correct - it properly clamps both
startandendto[0, rank]and handles thestart > endcase by returning an empty shape:This fix ensures the documentation accurately reflects the actual behavior, making it consistent with how ONNX Runtime handles these edge cases.
Fixes #6862.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.