latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.functional.addcdiv
- tensorplay.functional.addcdiv(input, tensor1, tensor2, *, value=1, out=None) Tensor[source]
Performs the element-wise division of
tensor1bytensor2, multiplies the result by the scalarvalueand adds it toinput.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 * tensorplay.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.
The shapes of
input,tensor1, andtensor2must be broadcastable.For inputs of type FloatTensor or DoubleTensor,
valuemust be a real number, otherwise an integer.- Parameters:
- Keyword Arguments:
value (Number, optional) – multiplier for
out (Tensor, optional) – the output tensor.
Example:
>>> t = tensorplay.randn(1, 3) >>> t1 = tensorplay.randn(3, 1) >>> t2 = tensorplay.randn(1, 3) >>> tensorplay.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]])
Help improve this page
Found an error, an unclear step, or a missing example?

