torch.linalg.vecdot¶
- torch.linalg.vecdot(x, y, *, dim=- 1, out=None) Tensor ¶
Computes the dot product of two batches of vectors along a dimension.
In symbols, this function computes
\[\sum_{i=1}^n \overline{x_i}y_i.\]over the dimension
dim
where \(\overline{x_i}\) denotes the conjugate for complex vectors, and it is the identity for real vectors.Supports input of half, bfloat16, float, double, cfloat, cdouble and integral dtypes. It also supports broadcasting.
- Parameters:
- Keyword Arguments:
Examples:
>>> v1 = torch.randn(3, 2) >>> v2 = torch.randn(3, 2) >>> linalg.vecdot(v1, v2) tensor([ 0.3223, 0.2815, -0.1944]) >>> torch.vdot(v1[0], v2[0]) tensor(0.3223)