Skip to content

Rewrite products of exponents as exponent of sum #54

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

Closed
ricardoV94 opened this issue Nov 29, 2022 · 2 comments
Closed

Rewrite products of exponents as exponent of sum #54

ricardoV94 opened this issue Nov 29, 2022 · 2 comments

Comments

@ricardoV94
Copy link
Member

Please describe the purpose of filing this issue

exp(x) * exp(y) => exp(x+y)
power(base, x) * power(base, y) => power(base, x + y)

From the top of my mind, I don't think such rewrite would affect numerical stability, but it should be faster...

import numpy as np

%timeit np.exp(9) * np.exp(2)
# 2.27 µs ± 53.5 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
%timeit np.exp(9+2)
# 1.11 µs ± 37 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

There was a PR for this in Theano that went stale: Theano/Theano#5272

Maybe we can borrow something from it.

@tamastokes
Copy link
Contributor

Hi, I started to look into this.

@ricardoV94
Copy link
Member Author

Closed via #186

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

No branches or pull requests

2 participants