fn

addcdiv

Tensor
addcdiv(input: Tensor, t1: Tensor, t2: Tensor, value: float = ...)
source

Element-wise fused divide-add.

Computes input+value(t1/t2)\text{input} + \text{value} \cdot (t_1 / t_2) in one expression. Common in optimiser updates (e.g. Adam's parameter step uses the form param -= lr * m / sqrt(v)).

Parameters

inputTensor
Accumulator tensor.
t1Tensor
Numerator. Must broadcast with input and t2.
t2Tensor
Denominator. Must broadcast with input and t1.
valuefloat
Scalar multiplier on the quotient. Defaults to 1.0.

Returns

Tensor

Tensor with the broadcast shape of the inputs.

Notes

Element-wise definition:

outi=inputi+value(t1)i(t2)i.\text{out}_i = \text{input}_i + \text{value} \cdot \frac{(t_1)_i}{(t_2)_i}.

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])