-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Fix pooling pads issues #6650
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
Fix pooling pads issues #6650
Conversation
2b69b98
to
71d6065
Compare
ed32535
to
280cd3c
Compare
Is there any wording to need to update in the spec? Just checking |
There was a spec ask: #1922 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6650 +/- ##
==========================================
- Coverage 57.50% 57.49% -0.01%
==========================================
Files 507 507
Lines 31624 31632 +8
Branches 3046 3048 +2
==========================================
+ Hits 18185 18187 +2
- Misses 12613 12618 +5
- Partials 826 827 +1 ☔ View full report in Codecov by Sentry. |
18bcb1b
to
a790113
Compare
@liqunfu @gramalingam @xadupre @justinchuby PTAL I am not sure if I will have to update the spec or something? |
e47ddaa
to
231f353
Compare
My newly added test is failing with onnx/test/test_backend_onnxruntime.py, which is expected because ORT also needs an update: microsoft/onnxruntime#16752. So should I disable the test for the time being? |
Yes. Please feel free to disable |
Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Deprecate all type casting functions because they are mere utilities or reference implementations that should not be directly exposed to users. Users should leverage libraries like `ml_dtypes` for type conversion. - Additionally turned convert_endian and split_complex_to_pairs into private. This is seen as low risk. - Added typing_extensions as a dependency. This is a common dependency used by python packages as a polyfill for the typing module. --------- Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com> Signed-off-by: titaiwangms <titaiwang@microsoft.com>
### Description Clarify in spec proto that FLOAT4E2M1 can be in int32_data, according to test usage. Updated text in the spec for int32_data for better readability and accuracy. ### Motivation and Context Previously the spec was incomplete according to the added tests. FLOAT4E2M1 was not yet released so the change should not require a new IR version. --------- Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com> Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Signed-off-by: titaiwangms <titaiwang@microsoft.com>
### Description Unify names of github environments I already updated the github environments. Signed-off-by: Andreas Fehlner <fehlner@arcor.de> Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Signed-off-by: titaiwangms <titaiwang@microsoft.com>
Signed-off-by: titaiwangms <titaiwang@microsoft.com>
f9765fc
to
1ba218d
Compare
Fix #16203 Previous to this PR, if `ceil_mode` is on, the calculation of a value would divide the kernel size, even if remaining pixels is less than the kernel size, which causes the difference in this operator between ORT and torch. However, this fix only applies to the change in #15597, which only supports AvgPool since 19. The older opset version is remain the same, as it's using mlas files. Also, the PR fixes the shape mismatch caused by sliding window starting from padding. More detail: onnx/onnx#6650 (And this PR is also validated with the tests added in onnx/onnx#6650)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need another eye on the logic
### Description Pooling in reference currently has two bugs: (1) it has ["pads required"](https://github.com/onnx/onnx/blob/e292b4ae6d016c3231a801bfeb26f802ba95d82a/onnx/reference/ops/op_pool_common.py#L53) to make sure sliding window does not go out-of-bound, but it does not exclude pads required from pooling caculations. This causes microsoft/onnxruntime#16203 (2) In `ceil_mode`, the reference pooling pads the input image, but does not check if sliding window starts on pads. When we reach the end of the image, the window should stop working. This causes pytorch/pytorch#131272. Not directly, but related fix on MaxPooling: #5741. Detail: pytorch/pytorch#116420 (comment) ### Motivation and Context This PR fixes the two bugs and update their tests accordingly. I also drafted a PR to onnxruntime to have this update in CPU provider: microsoft/onnxruntime#16752 --------- Signed-off-by: titaiwangms <titaiwang@microsoft.com> Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com> Signed-off-by: Andreas Fehlner <fehlner@arcor.de> Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com> Co-authored-by: Andreas Fehlner <fehlner@arcor.de> Signed-off-by: Andreas Fehlner <fehlner@arcor.de>
Fix #16203 Previous to this PR, if `ceil_mode` is on, the calculation of a value would divide the kernel size, even if remaining pixels is less than the kernel size, which causes the difference in this operator between ORT and torch. However, this fix only applies to the change in #15597, which only supports AvgPool since 19. The older opset version is remain the same, as it's using mlas files. Also, the PR fixes the shape mismatch caused by sliding window starting from padding. More detail: onnx/onnx#6650 (And this PR is also validated with the tests added in onnx/onnx#6650)
### Description Pooling in reference currently has two bugs: (1) it has ["pads required"](https://github.com/onnx/onnx/blob/e292b4ae6d016c3231a801bfeb26f802ba95d82a/onnx/reference/ops/op_pool_common.py#L53) to make sure sliding window does not go out-of-bound, but it does not exclude pads required from pooling caculations. This causes microsoft/onnxruntime#16203 (2) In `ceil_mode`, the reference pooling pads the input image, but does not check if sliding window starts on pads. When we reach the end of the image, the window should stop working. This causes pytorch/pytorch#131272. Not directly, but related fix on MaxPooling: onnx#5741. Detail: pytorch/pytorch#116420 (comment) ### Motivation and Context This PR fixes the two bugs and update their tests accordingly. I also drafted a PR to onnxruntime to have this update in CPU provider: microsoft/onnxruntime#16752 --------- Signed-off-by: titaiwangms <titaiwang@microsoft.com> Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com> Signed-off-by: Andreas Fehlner <fehlner@arcor.de> Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com> Co-authored-by: Andreas Fehlner <fehlner@arcor.de> Signed-off-by: seungwoo-ji <seungwoo.ji@nuvilab.com>
Fix #16203 Previous to this PR, if `ceil_mode` is on, the calculation of a value would divide the kernel size, even if remaining pixels is less than the kernel size, which causes the difference in this operator between ORT and torch. However, this fix only applies to the change in #15597, which only supports AvgPool since 19. The older opset version is remain the same, as it's using mlas files. Also, the PR fixes the shape mismatch caused by sliding window starting from padding. More detail: onnx/onnx#6650 (And this PR is also validated with the tests added in onnx/onnx#6650)
Fix #16203 Previous to this PR, if `ceil_mode` is on, the calculation of a value would divide the kernel size, even if remaining pixels is less than the kernel size, which causes the difference in this operator between ORT and torch. However, this fix only applies to the change in #15597, which only supports AvgPool since 19. The older opset version is remain the same, as it's using mlas files. Also, the PR fixes the shape mismatch caused by sliding window starting from padding. More detail: onnx/onnx#6650 (And this PR is also validated with the tests added in onnx/onnx#6650)
Description
Pooling in reference currently has two bugs:
(1) it has "pads required" to make sure sliding window does not go out-of-bound, but it does not exclude pads required from pooling caculations. This causes microsoft/onnxruntime#16203
(2) In
ceil_mode
, the reference pooling pads the input image, but does not check if sliding window starts on pads. When we reach the end of the image, the window should stop working. This causes pytorch/pytorch#131272. Not directly, but related fix on MaxPooling: #5741. Detail: pytorch/pytorch#116420 (comment)Motivation and Context
This PR fixes the two bugs and update their tests accordingly. I also drafted a PR to onnxruntime to have this update in CPU provider: microsoft/onnxruntime#16752