mindspore.mint.addmm

View Source On AtomGit
mindspore.mint.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 = \beta input + \alpha (mat1 @ mat2)\]

Warning

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

Parameters
  • input (Tensor) – The input tensor.

  • mat1 (Tensor) – The first matrix.

  • mat2 (Tensor) – The second matrix.

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

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

Returns

Tensor

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> m = mindspore.mint.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.]])
>>> mindspore.mint.addmm(m, arr1, arr2)
    Tensor(shape=[3, 3], dtype=Float32, value=
    [[ 1.03000000e+02,  8.20000000e+01,  6.10000000e+01],
     [ 5.80000000e+01,  4.60000000e+01,  3.40000000e+01],
     [ 1.30000000e+01,  1.00000000e+01,  7.00000000e+00]])