pytorch
d2b82feb - Don't compare ids of temporary python objects (#94097)

Commit
1 year ago
Don't compare ids of temporary python objects (#94097) Since `.data` creates a new Tensor and thus a new python object, this check checks the id of temporary objects and thus always succeed given the current behavior of python's allocator: ``` >>> import torch >>> print(id(torch.rand(2)) == id(torch.rand(3))) True ``` I change it here to make sure they look at the same memory. If you want to check that they are the same python object, I can change it to `is`. Let me know! Pull Request resolved: https://github.com/pytorch/pytorch/pull/94097 Approved by: https://github.com/malfet
Author
Committer
Parents
Loading