Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU tensor sum changes after transpose #4914

Closed
myleott opened this issue Jan 29, 2018 · 1 comment
Closed

GPU tensor sum changes after transpose #4914

myleott opened this issue Jan 29, 2018 · 1 comment

Comments

@myleott
Copy link
Contributor

myleott commented Jan 29, 2018

This happens intermittently with CUDA tensors, but never with CPU tensors:

>>> x = torch.rand(3, 4, 5).cuda()
>>> x.sum()
26.833271026611328
>>> x.transpose(0, 1).sum()
26.83327293395996

This happens both on a recent version of PyTorch (0.4.0a0+4970e73) and 0.3.0.

Is this expected behavior?

@apaszke
Copy link
Contributor

apaszke commented Jan 29, 2018

Yes, it's a result of floating point math being non-associative. In the second case the elements will be added in a different order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants