I am studying some code and I came across a usage of PyTorch's einsum function that I am not understanding. The docs are here.
The snippet looks like (slightly modified from the original):
import torch
x = torch.rand(64, 64, 25, 25)
y = torch.rand(64, 64, 64, 25)
result = torch.einsum('ncuv,nctv->nctu', x, y)
print(result.shape)
>> torch.Size([64, 64, 64, 25])
So the notation is such that n=64, c=64, u=25, v=25, t=64.
I'm not too sure what's happening. I think that for each 25 dimensional vector in t (64 of them), each one is being multiplied with each of the u=25 vectors of size 25 elementwise and then the results summed, or rather 25 dot products of 25 dimensional vectors?
Any insights appreciated.