Oddly enough, for very small tensor contractions, using reshape to reshape the Tensor storage data into a Matrix that gets passed to Blas.gemm! takes up a non-negligible amount of time. This appears to be a known issue: https://github.com/JuliaLang/julia/issues/36313
Oddly enough, for very small tensor contractions, using
reshape
to reshape theTensor
storage data into aMatrix
that gets passed toBlas.gemm!
takes up a non-negligible amount of time. This appears to be a known issue: https://github.com/JuliaLang/julia/issues/36313The most common place this is used is the
array(::Tensor)
constructor, here: https://github.com/ITensor/NDTensors.jl/blob/master/src/dense.jl#L355, but it is also used directly here: https://github.com/ITensor/NDTensors.jl/blob/master/src/dense.jl#L652An alternative might be to use a
Base.ReshapedArray
instead. It looks like it can still be passed to BLAS, for example: