Hi, I try to use
torch.einsum to replace
torch.matmul in my code for more intuitive, but the results between two op is not exactly equal.
x = torch.randn(3, 10)
y = torch.einsum('nc,mc->nm', x, x) - torch.matmul(x, x.T)
tensor([[ 0.0000e+00, 0.0000e+00, 0.0000e+00],
[ 0.0000e+00, -1.9073e-06, -1.1921e-07],
[ 0.0000e+00, -1.1921e-07, 4.7684e-07]])
Can someone explain to me why the result is unexpected?
I’d say that, given the fact einsum and matmul operates differently, the error is small enough to be considered as the same.