Add sqrt2 as constant for gelu_erf and use libm erf
#3168
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From the discussion here: #1926 (comment)
So I tried a couple of things, but wasn't making any progress and came across this post: https://users.rust-lang.org/t/high-performance-operations/19739
Essentially changing the constant operation from a division to a multiplication of the reciprocal does seem to have some improvement (difference between the 2 activations has reduced by 20ms)
Including some benchmark results here:
1000 RUNS, 1 ITERATION:
20 RUNS, 100 ITERATIONS:
Script to reproduce results: