mindspore.ops.addcmul

View Source On Gitee
mindspore.ops.addcmul(input, tensor1, tensor2, value=1)[source]

Multiply tensor1 by tensor2 element-wise, scale the result by the scalar value , and add it to input .

output[i]=input[i]+value[i](tensor1[i]tensor2[i])
Parameters
  • input (Tensor) – The input tensor.

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

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

  • value (Union[Tensor, number]) – The multiplier for ( tensor1 * tensor2 ). Default 1 .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> x = mindspore.tensor(([1, 1, 1]), mindspore.float32)
>>> x1 = mindspore.tensor([[1], [2], [3]], mindspore.float32)
>>> x2 = mindspore.tensor([[1, 2, 3]], mindspore.float32)
>>> y = mindspore.ops.addcmul(x, x1, x2, 1)
>>> print(y)
[[ 2.  3.  4.]
 [ 3.  5.  7.]
 [ 4.  7. 10.]]