oneflow.addcdiv

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

This function is equivalent to PyTorch’s addcdiv function. The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.addcdiv.html.

Performs the element-wise division of tensor1 by tensor2, multiply the result by the scalar value and add it to input.

\[\text{out}_i = \text{input}_i + \text{value} \times \frac{\text{tensor1}_i}{\text{tensor2}_i}\]

The shapes of input, tensor1, and tensor2 must be broadcastable.

For inputs of type FloatTensor or DoubleTensor, value must be a real number, otherwise an integer.

Parameters
  • input (Tensor) – the tensor to be added

  • tensor1 (Tensor) – the numerator tensor

  • tensor2 (Tensor) – the denominator tensor

Keyword Arguments

value (Number, optional) – multiplier for \(\text{{tensor1}} / \text{{tensor2}}\)

Example:

>>> import oneflow as flow
>>> input = flow.tensor([ 0.3810,  1.2774, -0.2972, -0.3719])
>>> tensor1 = flow.tensor([0.8032,  0.2930, -0.8113, -0.2308])
>>> tensor2 = flow.tensor([[0.5], [1]])
>>> output = flow.addcdiv(input, tensor1, tensor2)
>>> output.shape
oneflow.Size([2, 4])