mindspore.ops.addmv

View Source On Gitee
mindspore.ops.addmv(input, mat, vec, *, beta=1, alpha=1)[source]

Multiply the matrix mat and vector vec , and then add the result to the input .

Note

  • If mat is a (N,M) tensor, vec is a 1-D tensor of size M, then input must be broadcastable with a 1-D tensor of size N, out will be a 1-D tensor of size N.

  • If beta is 0, input will be ignored.

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

  • mat (Tensor) – The matrix tensor to be multiplied.

  • vec (Tensor) – The vector tensor to be multiplied.

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

  • alpha (scalar[int, float, bool], optional) – Scale factor for ( mat @ vec ). Default 1 .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input = mindspore.tensor([2., 3.])
>>> mat = mindspore.tensor([[2., 5., 3.], [4., 2., 2.]])
>>> vec = mindspore.tensor([3., 2., 4.])
>>> output = mindspore.ops.addmv(input, mat, vec)
>>> print(output)
[30. 27.]