julia> using OMEinsum
julia> a=rand(1024,1024);
julia> b=rand(1024,1024,2);
julia> using BenchmarkTools
julia> @btime ein"xy,yzw->xzw"(a,b);
23.790 ms (77 allocations: 16.00 MiB)
julia> @btime ein"yx,yzw->xzw"(a,b);
28.217 ms (101 allocations: 24.01 MiB)
As the example above shows, when I try to do this kind of index summation: ein"yx,yzw->xzw"(a,b), there’s always an extra memory allocation. This is equivalent to doing an index swap of the A matrix first using permutedims(), but I can always use permutedims!() to avoid additional memory allocation.
It seems that OMEinsum does not save this memory. When I actually use it, I get a lot of index summation operations, and I do a permutedims! every time I call ein operation can be tiring. My question is, does OMEinsum have any parameter settings that will save memory in this case?