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

Optimizing a sum of einsums? #179

Closed
yaroslavvb opened this issue Dec 22, 2021 · 2 comments
Closed

Optimizing a sum of einsums? #179

yaroslavvb opened this issue Dec 22, 2021 · 2 comments

Comments

@yaroslavvb
Copy link

I'm wondering if there are any plans to add a way to optimize a sum of einsums (or a related tool that does this?)

For instance

np.einsum('ij,jk,kl,lm,mn,np->ip',df1,df2,df3,df4,df5,df6)+np.einsum('in,np->ip',df1,df6)

There's a way to turn this into a single einsum, but this doubles the size of most tensors and makes them structured, while einsum seems to be optimized for unstructured tensors

@dgasmith
Copy link
Owner

Two ways to look at this:

  1. As structured, the only performance improvement seen is to exploit memory locality which is best left to other libraries.
  2. If you are restructuring this to observe the fact that there may be a shared intermediate, we do have capability for this operation.

Considering co-optimizing paths has been discussed, but tricky to do correctly. As before, there are several greedy heuristics which may perform well in practice however.

@yaroslavvb
Copy link
Author

I see, thanks for the info, shared intermediates seem appropriate here

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

2 participants