LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
lbann::cuTENSOR_PermuteImpl Class Reference

cuTENSOR-based implementation of tensor permute. More...

#include <cutensor_permuteimpl.hpp>

Collaboration diagram for lbann::cuTENSOR_PermuteImpl:
[legend]

Public Types

using DimsType = ColMajorDims< int64_t >
 
using StridesType = ColMajorStrides< int64_t >
 
using ModesType = std::vector< int32_t >
 

Public Member Functions

Lifecycle
 cuTENSOR_PermuteImpl (ColMajorPerm perm)
 
Read-only Accessors (for testing)
ColMajorPerm const & perm () const noexcept
 
DimsType const & input_dims () const noexcept
 
DimsType const & output_dims () const noexcept
 
ModesType const & input_modes () const noexcept
 
ModesType const & output_modes () const noexcept
 
StridesType input_strides () const
 
StridesType output_strides () const
 
Permute interface
void set_dims (DimsType input_dims)
 Setup the dimensions. More...
 
template<typename DataT >
void permute (El::Matrix< DataT, El::Device::GPU > const &in, El::Matrix< DataT, El::Device::GPU > &out) const
 Permute the tensor. More...
 
template<typename DataT >
void inverse_permute (El::Matrix< DataT, El::Device::GPU > const &in, El::Matrix< DataT, El::Device::GPU > &out) const
 Apply the inverse permutation to the tensor. More...
 
Modifiers
void swap (cuTENSOR_PermuteImpl &other)
 

Static Private Member Functions

static std::vector< int32_t > make_modes (size_t const ndims)
 
template<typename DataT >
static std::string get_desc_key (El::Matrix< DataT, El::Device::GPU > const &mat, DimsType const &dims)
 
template<typename DataT >
static cutensorTensorDescriptor_t get_descriptor (El::Matrix< DataT, El::Device::GPU > const &mat, DimsType const &dims)
 

Private Attributes

ColMajorPerm m_perm
 
DimsType m_input_dims
 
DimsType m_output_dims
 
ModesType m_input_modes
 
ModesType m_output_modes
 

Static Private Attributes

static std::unordered_map< std::string, cutensorTensorDescriptor_t > m_desc_map
 Keep track of descriptors so we don't have to repeatedly rebuild them. More...
 

Detailed Description

cuTENSOR-based implementation of tensor permute.

Because cuTENSOR is primarily column-major-centric (I actually prefer it, too, but that's neither here nor there), this caches as much as possible to avoid the annoying recomputation of dims, strides, etc.

Definition at line 55 of file cutensor_permuteimpl.hpp.

Member Typedef Documentation

◆ DimsType

Definition at line 58 of file cutensor_permuteimpl.hpp.

◆ ModesType

using lbann::cuTENSOR_PermuteImpl::ModesType = std::vector<int32_t>

Definition at line 60 of file cutensor_permuteimpl.hpp.

◆ StridesType

Constructor & Destructor Documentation

◆ cuTENSOR_PermuteImpl()

lbann::cuTENSOR_PermuteImpl::cuTENSOR_PermuteImpl ( ColMajorPerm  perm)
inline

Definition at line 150 of file cutensor_permuteimpl.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ get_desc_key()

template<typename DataT >
std::string lbann::cuTENSOR_PermuteImpl::get_desc_key ( El::Matrix< DataT, El::Device::GPU > const &  mat,
DimsType const &  dims 
)
staticprivate

Definition at line 204 of file cutensor_permuteimpl.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_descriptor()

template<typename DataT >
cutensorTensorDescriptor_t lbann::cuTENSOR_PermuteImpl::get_descriptor ( El::Matrix< DataT, El::Device::GPU > const &  mat,
DimsType const &  dims 
)
staticprivate

Definition at line 219 of file cutensor_permuteimpl.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ input_dims()

auto lbann::cuTENSOR_PermuteImpl::input_dims ( ) const
inlinenoexcept

Definition at line 163 of file cutensor_permuteimpl.hpp.

◆ input_modes()

auto lbann::cuTENSOR_PermuteImpl::input_modes ( ) const
inlinenoexcept

Definition at line 174 of file cutensor_permuteimpl.hpp.

◆ input_strides()

auto lbann::cuTENSOR_PermuteImpl::input_strides ( ) const
inline

Definition at line 186 of file cutensor_permuteimpl.hpp.

Here is the call graph for this function:

◆ inverse_permute()

template<typename DataT >
void lbann::cuTENSOR_PermuteImpl::inverse_permute ( El::Matrix< DataT, El::Device::GPU > const &  in,
El::Matrix< DataT, El::Device::GPU > &  out 
) const

Apply the inverse permutation to the tensor.

Applies the inverse permutation to the tensor represented by "in". In line with the rest of LBANN, the permutation is applied to each column, which is treated as a packed tensor with the dimensions stored in this object.

Definition at line 281 of file cutensor_permuteimpl.hpp.

Here is the call graph for this function:

◆ make_modes()

auto lbann::cuTENSOR_PermuteImpl::make_modes ( size_t const  ndims)
inlinestaticprivate

Definition at line 196 of file cutensor_permuteimpl.hpp.

Here is the caller graph for this function:

◆ output_dims()

auto lbann::cuTENSOR_PermuteImpl::output_dims ( ) const
inlinenoexcept

Definition at line 168 of file cutensor_permuteimpl.hpp.

◆ output_modes()

auto lbann::cuTENSOR_PermuteImpl::output_modes ( ) const
inlinenoexcept

Definition at line 180 of file cutensor_permuteimpl.hpp.

◆ output_strides()

auto lbann::cuTENSOR_PermuteImpl::output_strides ( ) const
inline

Definition at line 191 of file cutensor_permuteimpl.hpp.

Here is the call graph for this function:

◆ perm()

auto lbann::cuTENSOR_PermuteImpl::perm ( ) const
inlinenoexcept

Definition at line 158 of file cutensor_permuteimpl.hpp.

Here is the caller graph for this function:

◆ permute()

template<typename DataT >
void lbann::cuTENSOR_PermuteImpl::permute ( El::Matrix< DataT, El::Device::GPU > const &  in,
El::Matrix< DataT, El::Device::GPU > &  out 
) const

Permute the tensor.

Applies the permutation to the tensor represented by "in". In line with the rest of LBANN, the permutation is applied to each column, which is treated as a packed tensor with the dimensions stored in this object.

Note
(trb) I think this can be extended to support data type conversions during permutation, but I haven't tested this and there's currently not a known need.

Definition at line 255 of file cutensor_permuteimpl.hpp.

Here is the call graph for this function:

◆ set_dims()

void lbann::cuTENSOR_PermuteImpl::set_dims ( DimsType  input_dims)
inline

Setup the dimensions.

Must be compatible with the provided perm vector.

Definition at line 248 of file cutensor_permuteimpl.hpp.

Here is the call graph for this function:

◆ swap()

void lbann::cuTENSOR_PermuteImpl::swap ( cuTENSOR_PermuteImpl other)
inline

Definition at line 314 of file cutensor_permuteimpl.hpp.

Member Data Documentation

◆ m_desc_map

std::unordered_map<std::string, cutensorTensorDescriptor_t> lbann::cuTENSOR_PermuteImpl::m_desc_map
inlinestaticprivate

Keep track of descriptors so we don't have to repeatedly rebuild them.

Definition at line 130 of file cutensor_permuteimpl.hpp.

◆ m_input_dims

DimsType lbann::cuTENSOR_PermuteImpl::m_input_dims
private

Definition at line 144 of file cutensor_permuteimpl.hpp.

◆ m_input_modes

ModesType lbann::cuTENSOR_PermuteImpl::m_input_modes
private

Definition at line 146 of file cutensor_permuteimpl.hpp.

◆ m_output_dims

DimsType lbann::cuTENSOR_PermuteImpl::m_output_dims
private

Definition at line 145 of file cutensor_permuteimpl.hpp.

◆ m_output_modes

ModesType lbann::cuTENSOR_PermuteImpl::m_output_modes
private

Definition at line 147 of file cutensor_permuteimpl.hpp.

◆ m_perm

ColMajorPerm lbann::cuTENSOR_PermuteImpl::m_perm
private

Definition at line 143 of file cutensor_permuteimpl.hpp.


The documentation for this class was generated from the following file: