Skip to content
class

SinBackward

SinBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for element-wise sine y=sin⁡(x)y = \sin(x).

Saves the input x so the backward pass can evaluate cos⁡(x)\cos(x) and scale the upstream gradient by it. The input is interpreted in radians.

Math

\frac{\partial y}{\partial x} = \cos(x), \qquad \frac{\partial \mathcal{L}}{\partial x} = \cos(x)\,\frac{\partial \mathcal{L}}{\partial y}.$$

Attributes

schema_v1OpSchema
Registered as "sin" with AmpPolicy::Promote.

Notes

Dispatch: Accelerate vvsinf/vvsin (CPU) / MLX sin (GPU).

Static methods

1
static

dispatch

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

Forward — calls IBackend::sin to compute y=sin⁡xy = \sin x.

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Backward — ∂y/∂x=cos⁡x\partial y/\partial x = \cos x, scaled by grad_out.

fn

grad_formula_impl

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

Graph-mode backward: the same derivative built from composable ops, so the gradient itself stays differentiable.