fn
addcdiv
→Tensoraddcdiv(input: Tensor, t1: Tensor, t2: Tensor, value: float = ...)Element-wise fused divide-add.
Computes in
one expression. Common in optimiser updates (e.g. Adam's
parameter step uses the form param -= lr * m / sqrt(v)).
Parameters
inputTensorAccumulator tensor.
t1TensorNumerator. Must broadcast with
input and t2.t2TensorDenominator. Must broadcast with
input and t1.valuefloatScalar multiplier on the quotient. Defaults to
1.0.Returns
TensorTensor with the broadcast shape of the inputs.
Notes
Element-wise definition:
Division by zero follows standard IEEE 754 rules — no clamping is applied. Gradients flow through all three tensor operands.
Examples
>>> import lucid
>>> a = lucid.tensor([1.0, 2.0])
>>> t1 = lucid.tensor([4.0, 9.0])
>>> t2 = lucid.tensor([2.0, 3.0])
>>> lucid.addcdiv(a, t1, t2, value=0.5)
Tensor([2. , 3.5])