Hello everyone,
I have been working on a chunk of code that basically sets out to provide a
single function that can take an arbitrary einsum expression and computes it in
the most optimal way. While np.einsum can compute arbitrary expressions, there
are two drawbacks to using pure einsum: einsum does not consider building
intermediate arrays for possible reductions in overall rank and is not
currently capable of using a vendor BLAS. I have been working on a project that
aims to solve both issues simultaneously:
https://github.com/dgasmith/opt_einsum <https://github.com/dgasmith/opt_einsum>
This program first builds the optimal way to contract the tensors together, or
using my own nomenclature a “path.” This path is then iterated over and uses
tensordot when possible and einsum for everything else. In test cases the worst
case scenario adds a 20 microsecond overhead penalty and, in the best case
scenario, it can reduce the overall rank of the tensor. The primary (if
somewhat exaggerated) example is a 5-term N^8 index transformation that can be
reduced to N^5; even when N is very small (N=10) there is a 2,000 fold speed
increase over pure einsum or, if using tensordot, a 2,400 fold speed increase.
This is somewhat similar to the new np.linalg.multi_dot function.
If you are interested in this function please head over to the github repo and
check it out. I believe the README is starting to become self-explanatory, but
feel free to email me with any questions.
This originally started because I was looking into using numpy to rapidly
prototype quantum chemistry codes. The results of which can be found here:
https://github.com/dgasmith/psi4numpy <https://github.com/dgasmith/psi4numpy>
As such, I am very interested in implementing this into numpy. While I think
opt_einsum is in a pretty good place, there is still quite a bit to do (see
outstanding issues in the README). Even if this is not something that would fit
into numpy I would still be very interested in your comments.
Thank you for your time,
-Daniel Smith
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion