torch.matmul gives RuntimeError
I have two tensors
t1=torch.Size([400, 32, 400])
t2= torch.Size([400, 32, 32])

when i excute this
torch.matmul(t1,t2)
i got this error RuntimeError:

Expected tensor to have size 400 at dimension 1, but got size 32 for
argument #2 'batch2' (while checking arguments for bmm)

Any help will be much appreciated

You get the error because the order of matrix multiplication is wrong.
It should be:
a = torch.randn(400, 32, 400)
b = torch.randn(400, 32, 32)
out = torch.matmul(b, a) # You performed torch.matmul(a, b)

# You can also do a simpler version of the matrix multiplication using the below code
out = b @ a

