Table of Contents
Shortcuts

# 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

  ∑i=1 n x i‾y i.\sum_{i=1}^n \overline{x_i}y_i.i=1∑n​x i​​y i​.

  over the dimension `dim` where x i‾\overline{x_i}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:

    - x (Tensor) – first batch of vectors of shape (*, n).

    - y (Tensor) – second batch of vectors of shape (*, n).

  Keyword Arguments:

    - dim (int) – Dimension along which to compute the dot product. Default: -1.

    - out (Tensor, optional) – output tensor. Ignored if None. Default: None.

  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)

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.