Skip to content
class

HardSwishBackward

HardSwishBackward

Autograd node for Hard Swish y=x⋅hard_sigmoid(x)y = x \cdot \mathrm{hard\_sigmoid}(x) (Howard et al., MobileNetV3).

The derivative is the three-region piecewise function 00 for x≤−3x \le -3, (2x+3)/6(2x + 3)/6 for −3<x<3-3 < x < 3, and 11 for x≥3x \ge 3. Backward is delegated to the backend for a single fused pass.

Math

\qquad \frac{\partial y}{\partial x} = \begin{cases} 0, & x \le -3 \\ (2x + 3)/6, & -3 < x < 3 \\ 1, & x \ge 3 \end{cases}$$

Attributes

schema_v1OpSchema
"hard_swish", AmpPolicy::KeepInput.

Static methods

1
static

dispatch

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

Forward — calls IBackend::hard_swish to compute y=x⋅hard_sigmoid(x)y = x \cdot \mathrm{hard\_sigmoid}(x).

Methods

2
fn

grad_formula

int grad_formula(const int & g)

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

fn

grad_formula_impl

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