Skip to content

Consider changing the behavior of Tensor.__contains__(Tensor) to make more sense #24338

@zou3519

Description

@zou3519

🐛 Bug

import torch
x = torch.tensor([1, 2, 3])
y = torch.tensor([5, 6, 3])
y in x  # True

Expected behavior

This particular case should be False. Related: #17733 #24156
The incorrect semantics was introduced in PyTorch 1.2 (May), but no one else has complained about it yet in the three months since.

Environment

pytorch master.

cc @mruberry @rgommers @heitorschueroff

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: numpyRelated to numpy support, and also numpy compatibility of our operatorsmodule: uxtriagedThis 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