dgasmith / opt_einsum

⚡️Optimizing einsum functions in NumPy, Tensorflow, Dask, and more with contraction order optimization.
https://dgasmith.github.io/opt_einsum/
MIT License
863 stars 68 forks source link

contraction_list: only keep remaining for last 20 contractions #149

Closed jcmgray closed 4 years ago

jcmgray commented 4 years ago

Description

Resolves #148, by only keeping the last 10 'remaining terms' lists in the contraction_list, which is generally the point it starts to look a bit messy in the PathInfo object. This could be tweaked / made customizable.

I've also

>>> import opt_einsum as oe
>>> eq, shapes = oe.helpers.rand_equation(20, 3)
>>> path, info = oe.contract_path(eq, *shapes, shapes=True, optimize='greconf')
>>> info
  Complete contraction:  n,aA,jhr,mw,ox,Bos,dc,Cqeu,ipDs,tBk,v,tpkD,u,fram,byqx,znfgd,eCvlbz,icg,jw,yAhl->
         Naive scaling:  30
     Optimized scaling:  6
      Naive FLOP count:  1.680e+21
  Optimized FLOP count:  9.401e+4
   Theoretical speedup:  1.786e+16
  Largest intermediate:  3.888e+3 elements
--------------------------------------------------------------------------------
scaling        BLAS                current                             remaining
--------------------------------------------------------------------------------
   3           GEMM              jw,mw->jm                                   ...
   4           GEMM            jm,jhr->mhr                                   ...
   5           TDOT          mhr,fram->hfa                                   ...
   4           GEMM            hfa,aA->hfA                                   ...
   5    GEMV/EINSUM          znfgd,n->zfgd                                   ...
   4           TDOT            icg,dc->igd                                   ...
   5           GEMM          igd,zfgd->izf                                   ...
   5           TDOT          izf,hfA->izhA                                   ...
   6           TDOT        izhA,yAhl->izyl                                   ...
   5           TDOT          tpkD,tBk->pDB    ox,Bos,Cqeu,ipDs,v,u,byqx,eCvlbz,izyl,pDB->
   5           TDOT          pDB,ipDs->Bis    ox,Bos,Cqeu,v,u,byqx,eCvlbz,izyl,Bis->
   4           TDOT            Bis,Bos->io     ox,Cqeu,v,u,byqx,eCvlbz,izyl,io->
   3           GEMM              io,ox->ix        Cqeu,v,u,byqx,eCvlbz,izyl,ix->
   5           GEMM          ix,byqx->ibyq           Cqeu,v,u,eCvlbz,izyl,ibyq->
   6           TDOT        ibyq,izyl->bqzl                Cqeu,v,u,eCvlbz,bqzl->
   4           GEMM            u,Cqeu->Cqe                   v,eCvlbz,bqzl,Cqe->
   6           TDOT        Cqe,bqzl->Cebzl                      v,eCvlbz,Cebzl->
   6    GEMV/EINSUM        Cebzl,eCvlbz->v                                 v,v->
   1            DOT                  v,v->                                    ->

Status

codecov[bot] commented 4 years ago

Codecov Report

Merging #149 into master will decrease coverage by 0.05%. The diff coverage is 89.47%.

jcmgray commented 4 years ago

OK, raised number of 'remaining terms' kept to 20 and should have fixed #147 now as well.