Skip to content
class

MinimumBackward

MinimumBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for elementwise minimum y=min⁡(a,b)y = \min(a, b) with NumPy broadcasting.

Saves both inputs a and b (kSavesInputs = true inherited from BinaryKernel) so the backward pass can reconstruct the indicator masks for the comparison. The smaller operand takes the gradient, a tie splits it in half, and a NaN on either side gives it to both operands.

Math

yi=min⁡(ai,bi) y_i = \min(a_i, b_i) ∂L∂ai=w(ai,bi)⋅∂L∂yi,w(u,v)={1u<v or unordered12u=v0u>v \frac{\partial L}{\partial a_i} = w(a_i, b_i) \cdot \frac{\partial L}{\partial y_i}, \qquad w(u, v) = \begin{cases} 1 & u < v \text{ or unordered} \\ \tfrac12 & u = v \\ 0 & u > v \end{cases} ∂L∂bi=w(bi,ai)⋅∂L∂yi \frac{\partial L}{\partial b_i} = w(b_i, a_i) \cdot \frac{\partial L}{\partial y_i}

Shape

Inputs a, b follow NumPy broadcasting rules; the output takes the broadcast shape. Both gradient branches are sum-reduced back to their original input shapes by sum_to_shape in the apply trampoline.

See Also

MaximumBackward : Elementwise maximum (mirror operation).

Attributes

schema_v1OpSchema
"minimum", version 1, AmpPolicy::Promote, deterministic.

Notes

The rule is the reference's. Sending a tie wholly to a instead doubled the gradient of hypot and the complex abs at ∣a∣=∣b∣|a| = |b|, where both maximum and minimum of the same pair tie. A caller that wants a clamp's rule (a tie to a) uses clip or where, not minimum.

Static methods

1
static

dispatch

int dispatch(backend::IBackend & be, const int & a, const int & b, const int & shape, Dtype dt)

Route the forward computation through the backend's minimum primitive.

Methods

2
fn

grad_formula

int grad_formula(const int & grad_out)

Compute the gradients for both inputs given the output gradient.

fn

grad_formula_impl

int grad_formula_impl(const int & grad_out, const int & a, const int & b)