Is there a vectorized way to create a matrix in which each element is the the row-wise dot product of a matrix?
Apologize for the vagueness in the title, I spend some time rephrasing but cannot get it very well.
For example, I have a 2*3 matrix in Pytorch tensor
test = torch.tensor([[1, 10, 100],
                    [2, 20, 200]])

What I would like to have a final matrix that is
torch.tensor([10101, 20202],
             [20202, 40404])

Where we can see, the (0,0) position is the first row's dot product with itself, and (0,1) (1,0) is the dot product of first row and second row, (1,1) the the dot product of the second row with itself.
Thanks!

You can either do matrix multiplication:
test @ test.T

Or a torch.einsum:
torch.einsum('ij,kj-&gt;ik', test, test)

