TensorPermute#
This module reorders the axes of a tensor, with the axes of each side named by a spec.
permute("kij <- ijk", 0.0, &C, 1.0, A) sets C(k, i, j) = A(i, j, k), the same signature as the compute graph’s permute.
It works on the rank-erased TensorImpl that every tensor type wraps, and nothing in it is templated on the index letters.
A permutation can therefore be built at run time and rewritten as data, which is what the compute graph’s string specs need.
The kernel is HPTT. Building an HPTT plan is the expensive part of a small transpose, so plans are cached per thread, keyed on the shapes, and reused with new data and scalars.
See the API reference of this module for more details.
Public API#
permute- computesC = beta * C + alpha * permute(A), with the axes named by a spec such as"ji <- ij".transpose- computesC = A^Tfor matrices, and checks the ranks and the output’s size first.compile_permute- builds the plan without running it, for a permutation repeated on new data of the same shapes.
The typed einsums::tensor_algebra::permute, which names the axes with compile-time index types, is built on the same kernel and the same plan cache.