I want to do torch.dot on every tensor 1D (2 vectors) inside my 2D tensor

torch.dot(X, Y)

I want to get the result like this tensor([dotResult1, dotResult2]).
But I got the error like this:

RuntimeError: 1D tensors expected, but got 2D and 2D tensors

My main purpose is to do â€śsomethingâ€ť operation on every vector inside my matrix but I donâ€™t want to use looping here, does anyone know how to do that?

This will depend on what â€śsomethingâ€ť is. In general, you would want to
figure out how to do â€śsomethingâ€ť using pytorch tensor operations that act
on your 2D tensors all at once.

For your particular example of computing the dot products of the vectors
in your 2D tensors you can use element-wise multiplication and then sum
the rows or, equivalently, use the general purpose einsum() to do the same
thing: