-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Closed
Labels
high prioritymodule: numerical-stabilityProblems related to numerical stability of operationsProblems related to numerical stability of operationstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Bug
When using the CPU only (no CUDA), the in-place add function torch.Tensor.add_()
returns different values on different calls (with trivial differences) using some inputs. However, torch.Tensor.add()
does not.
To Reproduce
-
use this numpy array as an example https://raw.githubusercontent.com/sakhar/pytorch_add_bug/master/values-np.p
or values-np.p.zip (unzip). -
try it with
add_()
:
for i in range(10):
values = pickle.load(open('values-np.p','rb'))
x = torch.from_numpy(values[0])
y = torch.from_numpy(values[1])
print(x.add_(-0.7,y).data.detach().numpy()[-4])
results:
using add_():
-0.09407266
-0.094072655
-0.09407266
-0.094072655
-0.09407266
-0.09407266
-0.094072655
-0.094072655
-0.09407266
-0.09407266
- with
add()
:
for i in range(10):
values = pickle.load(open('values-np.p','rb'))
x = torch.from_numpy(values[0])
y = torch.from_numpy(values[1])
print(x.add(-0.7,y).data.detach().numpy()[-4])
results:
using add():
-0.094072655
-0.094072655
-0.094072655
-0.094072655
-0.094072655
-0.094072655
-0.094072655
-0.094072655
-0.094072655
-0.094072655
Environment
- PyTorch Version: 0.4.1
- OS: Mac OSX 10.12.6
- How you installed PyTorch: pip
- Python version: 2.7
- CUDA/cuDNN version: No CUDA
- GPU models and configuration: No CUDA
- Versions of relevant libraries:
[pip] numpy (1.14.5)
[pip] torch (0.4.1)
[pip] torchvision (0.2.1)
Metadata
Metadata
Assignees
Labels
high prioritymodule: numerical-stabilityProblems related to numerical stability of operationsProblems related to numerical stability of operationstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module