Template Class Permuter

Class Documentation

template<class PermuterBackend>
class Permuter

Interface for tensor permutation backend.

The Permuter class represents the front-end interface for calling permutations, which are a generalization of transposition to high-rank tensors. The class follows a composition-based approach, where we instantiate with a given backend permuter, who makes available two Transpose methods, one which returns the transform result, and another which modifies a reference directly.

Example 1: const std::vector<size_t> data_in {0,1,2,3,4,5}; std::vector<size_t> data_out(data_in.size(), 0); Permuter<DefaultPermuter<size_t>> p; p.Transpose(data_in, {2,3}, data_out, {“a”,”b”}, {“b”,”a”});

Example 2: const std::vector<size_t> data_in {0,1,2,3,4,5}; Permuter<DefaultPermuter<size_t>> p; auto data_out = p.Transpose(data_in, {2,3}, {“a”,”b”}, {“b”,”a”});

Template Parameters

PermuteBackend

Public Functions

template<class T>
inline void Transpose(const std::vector<T> &data_in, const std::vector<size_t> &shape, std::vector<T> &data_out, const std::vector<std::string> &current_order, const std::vector<std::string> &new_order)

Reshape the given lexicographic data vector from old to new index ordering.

Template Parameters

T – Data participating in the permutation.

Parameters
  • data_in – Input data to be transposed.

  • shape – Current shape of the tensor data in each dimension.

  • data_out – Output data following the transpose.

  • current_order – Current index ordering of the tensor.

  • new_order – New index ordering of the tensor.

template<class T>
inline std::vector<T> Transpose(const std::vector<T> &data_in, const std::vector<size_t> &shape, const std::vector<std::string> &current_order, const std::vector<std::string> &new_order)

Reshape the given lexicographic data vector from old to new index ordering.

Template Parameters

T – Data participating in the permutation.

Parameters
  • data_in – Input data to be transposed.

  • shape – Current shape of the tensor data in each dimension.

  • current_order – Current index ordering of the tensor.

  • new_order – New index ordering of the tensor.

Returns

std::vector<T> Output data following the transpose.

Protected Attributes

friend PermuterBackend