Table of Contents
Shortcuts

# torch.addcdiv

torch.addcdiv(input, tensor1, tensor2, *, value=1, out=None) → Tensor

  Performs the element-wise division of `tensor1` by `tensor2`, multiplies the result by the scalar `value` and adds it to `input`.

  Warning

  Integer division with addcdiv is no longer supported, and in a future release addcdiv will perform a true division of tensor1 and tensor2. The historic addcdiv behavior can be implemented as (input + value * torch.trunc(tensor1 / tensor2)).to(input.dtype) for integer inputs and as (input + value * tensor1 / tensor2) for float inputs. The future addcdiv behavior is just the latter implementation: (input + value * tensor1 / tensor2), for all dtypes.

  out i=input i+value×tensor1 i tensor2 i\text{out}_i = \text{input}_i + \text{value} \times \frac{\text{tensor1}_i}{\text{tensor2}_i} out i​=input i​+value×tensor2 i​tensor1 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 tensor1/tensor2\text{tensor1} / \text{tensor2}tensor1/tensor2

    - out (Tensor, optional) – the output tensor.

  Example:

      >>> t = torch.randn(1, 3)
      >>> t1 = torch.randn(3, 1)
      >>> t2 = torch.randn(1, 3)
      >>> torch.addcdiv(t, t1, t2, value=0.1)
      tensor([[-0.2312, -3.6496,  0.1312],
              [-1.0428,  3.4292, -0.1030],
              [-0.5369, -0.9829,  0.0430]])

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.