Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorization of tanh #191

Open
vedanuj opened this issue May 12, 2018 · 2 comments
Open

Vectorization of tanh #191

vedanuj opened this issue May 12, 2018 · 2 comments
Labels

Comments

@vedanuj
Copy link

vedanuj commented May 12, 2018

Recently I submitted a PR to the PyTorch Repo for a vectorized tanh implementation for single precision. The implementation is a vectorized version of cephes math library's single precision tanhf function. In PyTorch setting the implementation seemed faster than Sleef_tanhf8_u10 (I have posted some benchmark numbers in the PR here).

Are there any Sleef benchmarks that I can run to compare the implementation? In case it is faster are you open to a PR? Thanks!

@shibatch
Copy link
Owner

shibatch commented May 13, 2018

Hello @vedanuj,
Thank you for considering contribution. I'm open to a PR if your implementation is good enough. However, I cannot confirm if your implementation is good enough to adopt. Please consider checking the following points.

  • Is it an alternative to Sleef_tanhf8_u10? If so, please make sure that it's error is less than 1 ULP. It seems that you checked the correctness of your subroutine using a utility included in PyTorch, and it only took less than 1 second to check? That's not enough to check if the maximum error is less than the specified number. Please use tester2 included in libm-tester directory. Of course, you can use your own utility to check the maximum error.
  • Don't you have a double-precision implementation?
  • You also need to write the code using helper functions, like other functions in SLEEF.

I am now trying to implement 3.5-ULP versions of hyperbolic functions.

@blapie blapie added the algo label Nov 2, 2023
@Hamlin-Li
Copy link

Hamlin-Li commented Jul 4, 2024

We (openjdk) face the similar issues in this openjdk/jdk#18605 when using vector functions in sleef, we use inline header generated by sleef with -DSLEEF_BUILD_INLINE_HEADERS=ON flag.

For performance regression data, please check the tests: Float128Vector.TANH, Float64Vector.TANH, Double128Vector.TANH, other tests look fine.

BTW, previously we fixed (#537, #536), but it did not resolve the TANH issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants