Hey folks, have been haunted by this for some time. Now have an isolated repro. c1 and c2 below should be absolutely equal below but that’s not the case. Can anyone please explain why? The behavior is same on CPU and GPU.
import torch

d1=10
d2=2
d3=50
d4=150

torch.set_printoptions(20)

e=torch.rand((d1,d2,d3))
f=torch.rand((d3,d4))
r1=torch.matmul(e.view(-1,d3),f).view(d1,d2,d4)
r2=torch.matmul(e[:,-1,:].unsqueeze(1).view(-1,d3),f).view(d1,1,d4)

c1=r1[:,-1,:]
c2=r2[:,-1,:]
print(torch.equal(c1,c2))
print(torch.max(torch.abs(c1-c2)))
print(torch.min(torch.abs(c1-c2)))