mindspore.ops.addmm

View Source On Gitee
mindspore.ops.addmm(input, mat1, mat2, *, beta=1, alpha=1)[source]

Multiply matrix mat1 and matrix mat2. The matrix input is added to the final result.

Note

  • If beta is 0, then input will be ignored.

output=βinput+α(mat1@mat2)
Parameters
  • input (Tensor) – The input tensor.

  • mat1 (Tensor) – The first tensor to be multiplied.

  • mat2 (Tensor) – The second tensor to be multiplied.

Keyword Arguments
  • beta (Union[int, float], optional) – Scale factor for input. Default 1 .

  • alpha (Union[int, float], optional) – Scale factor for ( mat1 @ mat2 ) . Default 1 .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> m = mindspore.ops.ones((3, 3))
>>> arr1 = mindspore.tensor([[8., 7., 6.], [5., 4., 3.], [2., 1., 0.]])
>>> arr2 = mindspore.tensor([[5., 4., 3.], [2., 1., 0.], [8., 7., 6.]])
>>> output = mindspore.ops.addmm(m, arr1, arr2)
>>> print(output)
[[103.  82.  61.]
 [ 58.  46.  34.]
 [ 13.  10.   7.]]