Skip to content
class

CoshBackward

CoshBackward

Python wrappers

Public Python APIs implemented by this engine symbol.

Autograd node for element-wise hyperbolic cosine y=cosh⁡(x)y = \cosh(x).

Saves the input x so the backward pass can evaluate sinh⁡(x)\sinh(x). Defined on all of R\mathbb{R} with the identity cosh⁡(x)=(ex+e−x)/2≥1\cosh(x) = (e^x + e^{-x})/2 \geq 1.

Math

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

Attributes

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

Notes

Dispatch: Accelerate vvcoshf/vvcosh (CPU) / MLX cosh (GPU). Output magnitude grows exponentially.

Static methods

1
static

dispatch

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

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

Methods

2
fn

grad_formula

int grad_formula(const int & g)

Backward — ∂y/∂x=sinh⁡x\partial y/\partial x = \sinh 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.