Skip to content
class

Relu6Backward

Relu6Backward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for ReLU6 y=clamp(x,0,6)y = \mathrm{clamp}(x, 0, 6) (Krizhevsky 2010, MobileNet family).

Gradient is the indicator of the open interval (0,6)(0, 6) — built directly as an in-range storage mask and multiplied with the upstream gradient, avoiding a backend round-trip for this very simple piecewise rule.

Math

\qquad \frac{\partial y}{\partial x} = \begin{cases} 1, & 0 < x < 6 \\ 0, & \text{otherwise} \end{cases}$$

Attributes

schema_v1OpSchema
"relu6", AmpPolicy::KeepInput.

Static methods

1
static

dispatch

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

Forward — calls IBackend::relu6 to compute y=clamp(x,0,6)y = \mathrm{clamp}(x, 0, 6).

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Eager-mode backward: applies an in-range (0,6)(0, 6) mask to the upstream gradient.

fn

grad_formula_impl

int grad_formula_impl(const int & g, const int & x, const int & out)