Tullio.jl icon indicating copy to clipboard operation
Tullio.jl copied to clipboard

Alternative to Tullio for Chained Multiplication

Open prittjam opened this issue 3 years ago • 4 comments

The README tells why Tullio is slow for chained multiplication. Is there a tensor package that can be recommended for this use case? Thanks.

prittjam avatar Sep 21 '22 17:09 prittjam

Yes, TensorOperations ought to be good at this.

I believe it still decides the order of multiplication based only on the syntax, i.e. before knowing the sizes of the arrays. But it has an option to specify relative costs, https://jutho.github.io/TensorOperations.jl/stable/indexnotation/#Contraction-order-and-@tensoropt-macro

mcabbott avatar Sep 21 '22 17:09 mcabbott

Thanks for the response. Can you give a TL;DR version of when to prefer one package over the other?

prittjam avatar Sep 21 '22 18:09 prittjam

Yes, TensorOperations ought to be good at this.

I believe it still decides the order of multiplication based only on the syntax, i.e. before knowing the sizes of the arrays. But it has an option to specify relative costs, https://jutho.github.io/TensorOperations.jl/stable/indexnotation/#Contraction-order-and-@tensoropt-macro

Unfortunately, TensorOperations seems to have problems with StaticArrays. There seem to be some composability problems if you stray from the classic dynamic arrays. This holds true for Tullio as well with HybirdArrays.

prittjam avatar Sep 21 '22 19:09 prittjam

@mcabbott Is it possible to explicitly decompose computations using the pipe operator, as suggested in the documentation, to avoid the slowness of chained multiplication? For instance: Ξ(λ,Γp) = ( @tullio x[l,m,s] := -0.5*Γp[l,k]*Λ(λ)[k,m,s]) |> (x -> @tullio _[m,s] := Λ(λ)[l,m,s]*x[l,m,s] |> exp) Would this approach also help in avoiding the generation of intermediate variables?

swanchristmas avatar Mar 30 '24 06:03 swanchristmas