Skip to content

feat: add math/base/special/fast/gelu-tanh - #16174

Open
AryanSharma48 wants to merge 4 commits into
stdlib-js:developfrom
AryanSharma48:feat-add-fast-gelu-tanh
Open

AryanSharma48 wants to merge 4 commits into
stdlib-js:developfrom
AryanSharma48:feat-add-fast-gelu-tanh

Conversation

@AryanSharma48

Copy link
Copy Markdown
Contributor

Part of #15575

Description

What is the purpose of this pull request?

This pull request:

  • adds @stdlib/math/base/special/fast/gelu-tanh to evaluate the Gaussian Error Linear Unit (GELU) activation function using a tanh approximation.
  • implements the formulation using @stdlib/math/base/special/expit to avoid overflow and prevent numerical instability in the negative tail.
  • includes a native C implementation and Node-API bindings with fallback to pure JavaScript.
  • handles IEEE 754 edge cases including signed zeros, NaN, and ±Infinity.
  • includes unit tests with ULP tolerance assertions, C and JS benchmarks, usage examples, TypeScript declarations, and documentation.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

I consulted an AI assistant for research and mathematical understanding of the GELU tanh formulation and repository conventions, while the changes were authored in accordance with canonical @stdlib guidelines.


@stdlib-js/reviewers

Signed-off-by: Aryan Sharma <aryansharma24106@gmail.com>
@AryanSharma48
AryanSharma48 requested a review from a team October 15, 2026 14:29
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Oct 15, 2026
Signed-off-by: Aryan Sharma <aryansharma24106@gmail.com>
@stdlib-bot

stdlib-bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/fast/gelu-tanh $\\color{green}190/190$
$\\color{green}+0.00\\%$
$\\color{green}9/9$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}190/190$
$\\color{green}+0.00\\%$

The above coverage report was generated for the changes in this PR.

Signed-off-by: Aryan Sharma <aryansharma24106@gmail.com>
Signed-off-by: Aryan Sharma <aryansharma24106@gmail.com>

This branch has not been deployed

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

Labels

Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants