mindspore.ops.vecdot

View Source On Gitee
mindspore.ops.vecdot(x, y, *, axis=- 1)[source]

Calculates the dot product of two batches of vectors across the specified dimension.

The formula of calculation is as follows. \(\bar{x_{i}}\) represents the conjugate for complex vectors, and \(\bar{x_{i}}\) is the raw value for real vectors.

\[\sum_{i=1}^{n} \bar{x_{i}}{y_{i}}\]

Warning

This is an experimental API that is subject to change or deletion.

Parameters
  • x (Tensor) – First batch of vectors. The shape of Tensor is \((*,N)\) where \(*\) means, any number of additional dimensions. Supporting broadcasting. The dtype of Tensor should be one of the following types: float, double, int, complex64 and complex128.

  • y (Tensor) – Second batch of vectors. The shape of Tensor is \((*,N)\) where \(*\) means, any number of additional dimensions. Supporting broadcasting. The dtype of Tensor should be one of the following types: float, double, int, complex64 and complex128.

  • axis (int) – Dimension across which to calculate the dot product. Default: -1 .

Returns

Tensor, the shape is almost same as the shape of Tensor after broadcasting, while the specified dimension axis in shape has been removed.

Raises
Supported Platforms:

Ascend GPU CPU

Note

Currently, complex numbers are not supported on GPU.

Examples

>>> import mindspore as ms
>>> from mindspore import ops
>>> x = ms.Tensor([[1, 3], [5, 7], [9, 8]], dtype=ms.float32)
>>> y = ms.Tensor([[4, 5], [6, 7], [3, 2]], dtype=ms.float32)
>>> output = ops.vecdot(x, y, axis=-1)
>>> print(output)
[19. 79. 43.]