Open Geositta2000 opened 2 years ago
I would natively respond that the python overhead and repeated einsum
calls is the root problem; however, the overall time is larger than expected in the opt_einsum
route. I wonder if einsum
itself has a pathway which returns zero in the cases of a zero dimension index. We could add a similar pathway where we check if any index dimension is zero, we return zero as a result.
For contractions between tensors with various dimensions, sometimes the dimension may be zero, and I regarded it as a zero entry. Seems this is also what
einsum
does (refer to the code below, the result scalar is0.0
). For this type of contraction, seemsopt_einsum
is slower thaneinsum
(I use the pre-computed path to get rid of computing path time), for exampleThe result is
such that
einsum
is faster thanopt_einsum
. May I know why in this caseeinsum
is faster and is there any solution (I can write some code to detect zero dimension entry, but I hope it can somehow more robust)?