mindspore.mint.mm

mindspore.mint.mm(input, mat2)[source]

Returns the matrix product of two arrays. If input is a \((n \times m)\) Tensor, mat2 is a \((m \times p)\) Tensor, out will be a \((n \times p)\) Tensor.

Note

This function cannot support broadcasting. Refer to mindspore.ops.matmul() instead if you need a broadcastable function.

Warning

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

Parameters
  • input (Tensor) – The first matrix of matrix multiplication. The last dimension of input must be the same size as the first dimension of mat2.

  • mat2 (Tensor) – The second matrix of matrix multiplication. The last dimension of input must be the same size as the first dimension of mat2.

Returns

Tensor, the matrix product of the inputs.

Raises
  • ValueError – If the last dimension of input is not the same size as the second-to-last dimension of mat2.

  • TypeError – If input or mat2 is not a Tensor.

  • TypeError – If dtype of input or mat2 is not float16, float32 or bfloat16.

Supported Platforms:

Ascend

Examples

>>> import mindspore as ms
>>> from mindspore import mint
>>> import numpy as np
>>> x1 = ms.Tensor(np.random.rand(2, 3), ms.float32)
>>> x2 = ms.Tensor(np.random.rand(3, 4), ms.float32)
>>> out = mint.mm(x1, x2)
>>> print(out.shape)
(2, 4)