Skip to content
class

SigmoidBackward

SigmoidBackward

Python wrappers

Public Python APIs implemented by this engine symbols.

Autograd node for the logistic sigmoid y=1/(1+e−x)y = 1 / (1 + e^{-x}).

Saves the output yy rather than the input because the gradient formula y(1−y)y(1 - y) depends only on yy. This avoids a redundant forward pass and keeps the saved tensor at the same dtype as the activation.

Math

y=11+e−x,∂y∂x=y (1−y)y = \frac{1}{1 + e^{-x}}, \qquad \frac{\partial y}{\partial x} = y\,(1 - y)

Attributes

schema_v1OpSchema
"sigmoid", AmpPolicy::Promote — half-precision inputs are promoted to float32 to keep e−xe^{-x} from underflowing for large ∣x∣|x|.

Notes

The eager backward builds (1−y)(1 - y) via mul_scalar(-1) + add_scalar(1) to reuse the existing storage primitives rather than introducing a dedicated subtract kernel.

Static methods

1
static

dispatch

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

Forward — calls IBackend::sigmoid to compute y=1/(1+e−x)y = 1 / (1 + e^{-x}).

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Eager-mode backward: ∂L/∂x=y(1−y)⋅∂L/∂y\partial L/\partial x = y(1 - y) \cdot \partial L/\partial y using the saved output yy.

fn

grad_formula_impl

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

Graph-mode backward: out * (1 - out) * g expressed as composable ops so the chain remains differentiable.