mindspore.mint.matmul

mindspore.mint.matmul(input, other)[源代码]

计算两个输入的矩阵乘积。

说明

  • inputother 的数据类型必须一致,不支持Scalar,两者须支持广播。

  • Ascend平台, inputother 的秩必须在 1 到 6 之间。

参数:
  • input (Tensor) - 第一个输入tensor。

  • other (Tensor) - 第二个输入tensor。

返回:

Tensor或Scalar

支持平台:

Ascend

样例:

>>> 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])