Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support __rmod__ #58035

Closed
asi1024 opened this issue May 11, 2021 · 1 comment
Closed

Support __rmod__ #58035

asi1024 opened this issue May 11, 2021 · 1 comment
Labels
feature A request for a proper, new feature. module: python array api Issues related to the Python Array API triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@asi1024
Copy link
Contributor

asi1024 commented May 11, 2021

馃殌 Feature

Support aten::remainder for Scalar x Tensor inputs (aten::remainder(Scalar, Tensor)), and torch.Tensor.__rmod__.
(cc: @mruberry, @rgommers, @emcastillo and @kmaehashi)

Motivation and Pitch

To enhance the compatibility with NumPy鈥檚 interface (c.f. #38349).

>>> 5 % numpy.array([1, 2, 3, 4, 5])
array([0, 1, 2, 1, 0])
>>> 5 % torch.tensor([1, 2, 3, 4, 5])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for %: 'int' and 'Tensor'

References

@mruberry mruberry added feature A request for a proper, new feature. module: python array api Issues related to the Python Array API triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels May 12, 2021
@mruberry
Copy link
Collaborator

Thanks @asi1024; we would accept a PR implementing this functionality

@asi1024 asi1024 mentioned this issue May 18, 2021
1 task
deniskokarev pushed a commit to deniskokarev/pytorch that referenced this issue Jun 9, 2021
Summary:
Fixes pytorch#58035.

This PR implements `torch.Tensor.__rmod__` and `torch.remainder(scalar, tensor)` for the compatibility with NumPy鈥檚 interface.
(cc: mruberry, rgommers, emcastillo, kmaehashi)

TODO:
  - [x] Update `tensor_binary_op` in test/test_binary_ufuncs.py after pytorch#58216 is merged.

Pull Request resolved: pytorch#58476

Reviewed By: ngimel

Differential Revision: D28776810

Pulled By: mruberry

fbshipit-source-id: 74f8aea80f439ef2cc370333524e39971eeb7bf4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A request for a proper, new feature. module: python array api Issues related to the Python Array API triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants