Commit 63b1ae6
Fix overflow in torch.remainder when dividend is very large (#37758)
Summary:
This will fix the GPU implementation in #37743 and #24861. Please also check my [comment](#37743 (comment)).
The fixed `remainder_kernel` follows the similar implementation in numpy. See https://github.com/numpy/numpy/blob/79d7bc276afbe89c746e462d28d4bfbb4fc56148/numpy/core/src/npymath/npy_math_internal.h.src#L649-L658
I also slightly update the doc for `torch.remainder`, to make it similar to `torch.fmod`.
I'm not sure how to modify the Vec256 code of CPU remainder_kernel, so I just leave it there.
Pull Request resolved: #37758
Differential Revision: D21388417
Pulled By: ngimel
fbshipit-source-id: 770ba5801cf34619b2b68b8b0cf95d8cfa52e6f61 parent fdc4061 commit 63b1ae6
3 files changed
Lines changed: 26 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15449 | 15449 | | |
15450 | 15450 | | |
15451 | 15451 | | |
| 15452 | + | |
| 15453 | + | |
| 15454 | + | |
| 15455 | + | |
| 15456 | + | |
| 15457 | + | |
| 15458 | + | |
| 15459 | + | |
| 15460 | + | |
| 15461 | + | |
| 15462 | + | |
| 15463 | + | |
| 15464 | + | |
| 15465 | + | |
| 15466 | + | |
| 15467 | + | |
| 15468 | + | |
| 15469 | + | |
| 15470 | + | |
| 15471 | + | |
| 15472 | + | |
15452 | 15473 | | |
15453 | 15474 | | |
15454 | 15475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4902 | 4902 | | |
4903 | 4903 | | |
4904 | 4904 | | |
4905 | | - | |
4906 | | - | |
| 4905 | + | |
| 4906 | + | |
4907 | 4907 | | |
4908 | 4908 | | |
4909 | 4909 | | |
| |||
0 commit comments