Skip to content
class

HardSigmoidBackward

HardSigmoidBackward

Autograd node for the Hard Sigmoid y=clamp((x+3)/6,0,1)y = \mathrm{clamp}((x + 3)/6, 0, 1) (Howard et al., MobileNetV3).

The derivative is the indicator of the active linear region −3<x<3-3 < x < 3, scaled by 1/61/6. Backward goes through the backend to share the piecewise kernel with the other hard-* activations.

Math

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

Attributes

schema_v1OpSchema
"hard_sigmoid", AmpPolicy::KeepInput.

Static methods

1
static

dispatch

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

Forward — calls IBackend::hard_sigmoid to compute y=clamp((x+3)/6,0,1)y = \mathrm{clamp}((x + 3)/6, 0, 1).

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Eager-mode backward: dispatches to IBackend::hard_sigmoid_backward.

fn

grad_formula_impl

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