Fix integer overflow in remainder operator#5906
Fix integer overflow in remainder operator#5906soumith merged 4 commits intopytorch:masterfrom vedanuj:fix_int_overflow
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 : |
zou3519
left a comment
There was a problem hiding this comment.
This looks great! One minor comment
| // 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 |
* 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)
* 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@286a259). 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