Skip to content

Add fast tanh and fast sigmoid to LSTM#43

Merged
sdatkinson merged 1 commit into
sdatkinson:mainfrom
mikeoliphant:lstm_fast_activation
May 27, 2023
Merged

Add fast tanh and fast sigmoid to LSTM#43
sdatkinson merged 1 commit into
sdatkinson:mainfrom
mikeoliphant:lstm_fast_activation

Conversation

@mikeoliphant

Copy link
Copy Markdown
Contributor

This PR adds fast tanh and fast sigmoid activation for LSTM models. It keys off of the enable_fast_tanh()/disable_fast_tanh() methods.

My testing indicates around a 40% performance improvement for LSTM models.

@sdatkinson sdatkinson left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍🏻

Comment thread NAM/activations.h

inline float fast_sigmoid(const float x)
{
return 0.5f * (fast_tanh(x * 0.5f) + 1.0f);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct ✅

Comment thread NAM/activations.cpp
@sdatkinson sdatkinson merged commit 0dc9283 into sdatkinson:main May 27, 2023
@mikeoliphant mikeoliphant deleted the lstm_fast_activation branch June 16, 2023 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants