Skip to content

Support __rand__, __ror__ and __rxor__ #58120

@asi1024

Description

@asi1024

🚀 Feature

Support torch.Tensor.{__rand__, __ror__, __rxor__}.
(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([1, 0, 1, 4, 5])
>>> 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

cc @mruberry @rgommers @heitorschueroff

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