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

Any plan for trigonometric functions? #2

Open
fxpineau opened this issue Jan 3, 2023 · 5 comments
Open

Any plan for trigonometric functions? #2

fxpineau opened this issue Jan 3, 2023 · 5 comments

Comments

@fxpineau
Copy link

fxpineau commented Jan 3, 2023

In a short/medium/long term?
They are supported in rug or astro-float. See also, e.g., this paper.

@nadavrot
Copy link
Owner

nadavrot commented Jan 4, 2023

Hey @fxpineau. Yes, I think that I'll work on implementing them. I already implemented e and pi, and started reading on log and exp. The paper that you attached looks excellent. Btw, if you are interested in implementing something then that would be great. You can start with something small. I would love to review the pull request.

@nadavrot
Copy link
Owner

nadavrot commented Jan 6, 2023

I landed a quick implementation of sine(). It's incomplete, and we are still missing support for Inf,NaN, etc. And the Taylor series is unbounded, but the implementation can already compute a bunch of normal values in double precision and get bit accurate results.

@fxpineau
Copy link
Author

fxpineau commented Jan 6, 2023

For a lib I am working on, I am computing rotation matrices obtained from Euler angles and compare them to (high precision) matrices provided by the literature.
I am doing one shot computations (hard coding the result in the lib) and I finally chose to write bc scripts.
If cosine() is also implemented, I will compare bc and arpfloat results.
I may also extend the lib with high precision computations and arpfloat seems a very good candidate to me.

@nadavrot
Copy link
Owner

I implemented Sin, Cos, Tan, Exp, Log, Pow, and a few constants (pi, e, ln2). Can you think of other functions or constants?

@chadbrewbaker
Copy link

chadbrewbaker commented Feb 20, 2023

Doing a quick cprofile of nanoGPT model training on M1 CPU for the perf7 proposal:

ncalls tottime percall cumtime percall filename:lineno(function)
440 6.682 0.015 6.682 0.015 {method 'run_backward' of 'torch._C._EngineBase' objects}
1920 1.183 0.001 1.183 0.001 {built-in method torch.tanh}

It looks like torch.tanh() is really expensive and could use some love.

BSD tanh() seems really branchy.
GNU tahh()

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

No branches or pull requests

3 participants