Skip to content

Support __rmod__ #58035

@asi1024

Description

@asi1024

🚀 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’s 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA request for a proper, new feature.module: python array apiIssues related to the Python Array APItriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions