Skip to content

onnx: Sinh, Cosh, and the inverse hyperbolics #121

Description

@sbryngelson

Sinh/Cosh/Asinh/Acosh/Atanh are Unsupported natively (see _op_catalog.py) but decompose to ops the emitter already has, the same way aneforge/special.py handles the other walled math: sinh = (exp(x) - exp(-x)) / 2, cosh = (exp(x) + exp(-x)) / 2, asinh = log(x + sqrt(x*x + 1)), acosh = log(x + sqrt(x*x - 1)), atanh = 0.5 * log((1 + x) / (1 - x)). If special.py grows these first, the ONNX handler just routes to them; otherwise inline the decomposition in aneforge/onnx.py.

Watch the fp16 range: cosh/sinh overflow near x = ln(65504) ~ 11, the same cliff softplus hit in #113 -- document it (and clamp if you follow that precedent). Oracle is onnxruntime over the finite range. Build-level tests off-device via the _model helper in tests/test_onnx.py; the numeric match against onnxruntime dispatches, so run those on device and state in the PR that they passed locally.

Verifying numerics needs any Apple Silicon Mac (the tests dispatch to the ANE); CI runs only the off-device subset.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions