mindspore.mint.matmul

View Source On Gitee
mindspore.mint.matmul(input, other)[source]

Return the matrix product of two tensors.

Note

  • The dtype of input and other must be same.

  • On Ascend, the rank of input or other must be between 1 and 6.

Parameters
  • input (Tensor) – The first input tensor.

  • other (Tensor) – The second input tensor.

Returns

Tensor or scalar

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> # case 1 : Reasonable application of broadcast mechanism.
>>> input = mindspore.ops.arange(24).reshape(2, 3, 4)
>>> other = mindspore.ops.arange(20).reshape(4, 5)
>>> mindspore.mint.matmul(input, other)
Tensor(shape=[2, 3, 5], dtype=Int64, value=
[[[  70,   76,   82,   88,   94],
  [ 190,  212,  234,  256,  278],
  [ 310,  348,  386,  424,  462]],
 [[ 430,  484,  538,  592,  646],
  [ 550,  620,  690,  760,  830],
  [ 670,  756,  842,  928, 1014]]])
>>>
>>> # case 2 : The rank of `input` is 1.
>>> input = mindspore.ops.ones(([1, 2]))
>>> other = mindspore.ops.ones(([2]))
>>> mindspore.mint.matmul(input, other)
Tensor(shape=[1], dtype=Float32, value= [ 2.00000000e+00])