-
Notifications
You must be signed in to change notification settings - Fork 22.2k
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 integer overflow in remainder operator #5906
Conversation
Nice catch, @vedanuj! From the code changes, it looks like integer overflow from the multiplication is causing the issue. Is this correct? In the issue, the @robert-wagner mentioned two failure cases. Let
I listed an example of the first failure case in the issue; do you have an example of the second failure case, @robert-wagner? |
Hmm also see the failing tests (hit Details). |
@zou3519 Yes the integer overflow was causing the issue. I will add the tests and check why the test cases are failing. |
x = torch.tensor(-23500, dtype=torch.int64) |
The new commits fix the remainder operator in Cuda. Add tests in Tests :
|
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.
This looks great! One minor comment
aten/src/TH/generic/THTensorMath.c
Outdated
@@ -1070,7 +1070,7 @@ void THTensor_(remainder)(THTensor *r_, THTensor *t, real value) | |||
#else | |||
// There is no NAN for integers | |||
rp[i] = tp[i] % value; | |||
if (rp[i] * value < 0) | |||
if ((rp[i] < 0) != (value < 0)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@pytorchbot retest this please |
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.
This is great! Thanks @vedanuj!
* Fix integer overflow in remainder * Fix remainder operator in CUDA * Add tests for remainder integer overflow * Add has_different_sign static function
…#5906) Summary: Pull Request resolved: pytorch/glow#5906 Pull Request resolved: pytorch#71883 Fixes slice_tensor retracing. Include fix for retrace coverage. Missed in D33760455 (pytorch@66939e3). Test Plan: CI Reviewed By: wushirong Differential Revision: D33802222 fbshipit-source-id: 6796d65ea79107c0fcc577b583601f7c2dd35db1
Summary: Pull Request resolved: pytorch/glow#5906 Pull Request resolved: #71883 Fixes slice_tensor retracing. Include fix for retrace coverage. Missed in D33760455 (66939e3). Test Plan: CI Reviewed By: wushirong Differential Revision: D33802222 fbshipit-source-id: 4e0e44ae4a4eb70b99d79f0cd582182031b87e25
Summary: Pull Request resolved: pytorch/glow#5906 Pull Request resolved: #71883 Fixes slice_tensor retracing. Include fix for retrace coverage. Missed in D33760455 (66939e3). Test Plan: CI Reviewed By: wushirong Differential Revision: D33802222 fbshipit-source-id: 4e0e44ae4a4eb70b99d79f0cd582182031b87e25 (cherry picked from commit 98fd23c)
This PR fixes issue #5875 . Fixes integer overflow due to multiplication.
Please review @zou3519