oneflow.addcmul

oneflow.addcmul(input, tensor1, tensor2, *, value=1)Tensor

Performs the element-wise multiplication of tensor1 by tensor2, multiply the result by the scalar value and add it to input. The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.addcmul.html

\[\text{out}_i = \text{input}_i + value \times\ \text{tensor1}_i \times\ \text{tensor2}_i\]
Parameters
  • input (Tensor) – the tensor to be added.

  • tensor1 (Tensor) – the tensor to be multiplied.

  • tensor2 (Tensor) – the tensor to be multiplied.

Keyword Arguments

value (Number, optional) – multiplier for \(tensor1 * tensor2\).

Returns

the output Tensor.

Return type

oneflow.Tensor

For example:

>>> import oneflow as flow

>>> input = flow.rand(2, 3, 4)
>>> tensor1 = flow.rand(2, 3, 4)
>>> tensor2 = flow.rand(2, 3, 4)
>>> out = flow.addcmul(input, tensor1, tensor2, value=2)
>>> out.size()
oneflow.Size([2, 3, 4])