LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
lbann::cuTT_PermuteImpl Class Reference

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

#include <cutt_permuteimpl.hpp>

Collaboration diagram for lbann::cuTT_PermuteImpl:
[legend]

Public Types

using DimsType = ColMajorDims< int >
 

Public Member Functions

Lifecycle
 cuTT_PermuteImpl (ColMajorPerm perm)
 
 ~cuTT_PermuteImpl () noexcept
 
Read-only Accessors (for testing)
ColMajorPerm const & perm () const noexcept
 
DimsType const & input_dims () const noexcept
 
DimsType const & output_dims () const noexcept
 
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 (cuTT_PermuteImpl &other)
 

Private Types

using BatchSizeT = El::Int
 
using Plan = cuttHandle
 
using PlanMap = std::unordered_map< BatchSizeT, Plan >
 

Private Member Functions

template<typename DataT >
cuttHandle get_mb_plan (PlanMap &plan_map, ColMajorPerm const &perm, DimsType const &in_dims, DimsType const &out_dims, El::Matrix< DataT, El::Device::GPU > const &in, El::Matrix< DataT, El::Device::GPU > const &out) const
 
template<typename DataT >
cuttHandle get_sample_plan (ColMajorPerm const &perm, DimsType const &in_dims, DimsType const &out_dims, El::Matrix< DataT, El::Device::GPU > const &in, El::Matrix< DataT, El::Device::GPU > const &out) const
 
template<typename DataT >
bool is_mb_permutable (El::Matrix< DataT, El::Device::GPU > const &in, El::Matrix< DataT, El::Device::GPU > const &out) const
 
template<typename DataT >
void do_mb_permute (PlanMap &plan_map, ColMajorPerm const &perm, DimsType const &in_dims, DimsType const &out_dims, El::Matrix< DataT, El::Device::GPU > const &in, El::Matrix< DataT, El::Device::GPU > &out) const
 
template<typename DataT >
void do_sample_permute (Plan &plan, ColMajorPerm const &perm, DimsType const &in_dims, DimsType const &out_dims, El::Matrix< DataT, El::Device::GPU > const &in, El::Matrix< DataT, El::Device::GPU > &out) const
 

Private Attributes

ColMajorPerm m_perm
 
ColMajorPerm m_inv_perm
 
DimsType m_input_dims
 
DimsType m_output_dims
 
PlanMap m_fwd_plans
 
PlanMap m_inv_plans
 
Plan m_sample_fwd_plan = 0U
 
Plan m_sample_inv_plan = 0U
 

Detailed Description

cuTT-based implementation of tensor permute.

cuTT only supports packed tensors. LBANN currently assumes that all sample tensors are packed, so this is generally fine. However, LBANN allows the minibatch storage matrices to have a leading dimension that exceeds the height. This class handles this allowance by branching the code based on the relationship of the leading dimension and the height of the input/output matrices. When possible, it will create a transpose plan for the entire minibatch and launch a single kernel. When this is not possible, it will create a plan to transpose each sample and apply it sample-wise.

When a plan for the entire minibatch is possible, it will be required to create a new plan for any different minibatch size encountered.

Definition at line 93 of file cutt_permuteimpl.hpp.

Member Typedef Documentation

◆ BatchSizeT

using lbann::cuTT_PermuteImpl::BatchSizeT = El::Int
private

Definition at line 152 of file cutt_permuteimpl.hpp.

◆ DimsType

Definition at line 96 of file cutt_permuteimpl.hpp.

◆ Plan

using lbann::cuTT_PermuteImpl::Plan = cuttHandle
private

Definition at line 153 of file cutt_permuteimpl.hpp.

◆ PlanMap

using lbann::cuTT_PermuteImpl::PlanMap = std::unordered_map<BatchSizeT, Plan>
private

Definition at line 154 of file cutt_permuteimpl.hpp.

Constructor & Destructor Documentation

◆ cuTT_PermuteImpl()

lbann::cuTT_PermuteImpl::cuTT_PermuteImpl ( ColMajorPerm  perm)
inline

Definition at line 209 of file cutt_permuteimpl.hpp.

Here is the call graph for this function:

◆ ~cuTT_PermuteImpl()

lbann::cuTT_PermuteImpl::~cuTT_PermuteImpl ( )
inlinenoexcept

Definition at line 216 of file cutt_permuteimpl.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ do_mb_permute()

template<typename DataT >
void lbann::cuTT_PermuteImpl::do_mb_permute ( PlanMap plan_map,
ColMajorPerm const &  perm,
DimsType const &  in_dims,
DimsType const &  out_dims,
El::Matrix< DataT, El::Device::GPU > const &  in,
El::Matrix< DataT, El::Device::GPU > &  out 
) const
private

Definition at line 358 of file cutt_permuteimpl.hpp.

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

◆ do_sample_permute()

template<typename DataT >
void lbann::cuTT_PermuteImpl::do_sample_permute ( Plan plan,
ColMajorPerm const &  perm,
DimsType const &  in_dims,
DimsType const &  out_dims,
El::Matrix< DataT, El::Device::GPU > const &  in,
El::Matrix< DataT, El::Device::GPU > &  out 
) const
private

Definition at line 374 of file cutt_permuteimpl.hpp.

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

◆ get_mb_plan()

template<typename DataT >
cuttHandle lbann::cuTT_PermuteImpl::get_mb_plan ( PlanMap plan_map,
ColMajorPerm const &  perm,
DimsType const &  in_dims,
DimsType const &  out_dims,
El::Matrix< DataT, El::Device::GPU > const &  in,
El::Matrix< DataT, El::Device::GPU > const &  out 
) const
private

Definition at line 258 of file cutt_permuteimpl.hpp.

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

◆ get_sample_plan()

template<typename DataT >
cuttHandle lbann::cuTT_PermuteImpl::get_sample_plan ( ColMajorPerm const &  perm,
DimsType const &  in_dims,
DimsType const &  out_dims,
El::Matrix< DataT, El::Device::GPU > const &  in,
El::Matrix< DataT, El::Device::GPU > const &  out 
) const
private

Definition at line 288 of file cutt_permuteimpl.hpp.

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

◆ input_dims()

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

Definition at line 241 of file cutt_permuteimpl.hpp.

◆ inverse_permute()

template<typename DataT >
void lbann::cuTT_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 334 of file cutt_permuteimpl.hpp.

Here is the call graph for this function:

◆ is_mb_permutable()

template<typename DataT >
bool lbann::cuTT_PermuteImpl::is_mb_permutable ( El::Matrix< DataT, El::Device::GPU > const &  in,
El::Matrix< DataT, El::Device::GPU > const &  out 
) const
private

Definition at line 307 of file cutt_permuteimpl.hpp.

Here is the caller graph for this function:

◆ output_dims()

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

Definition at line 246 of file cutt_permuteimpl.hpp.

◆ perm()

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

Definition at line 236 of file cutt_permuteimpl.hpp.

◆ permute()

template<typename DataT >
void lbann::cuTT_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.

Definition at line 316 of file cutt_permuteimpl.hpp.

Here is the call graph for this function:

◆ set_dims()

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

Setup the dimensions.

Must be compatible with the provided perm vector.

Definition at line 251 of file cutt_permuteimpl.hpp.

Here is the call graph for this function:

◆ swap()

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

Definition at line 400 of file cutt_permuteimpl.hpp.

Member Data Documentation

◆ m_fwd_plans

PlanMap lbann::cuTT_PermuteImpl::m_fwd_plans
mutableprivate

Definition at line 203 of file cutt_permuteimpl.hpp.

◆ m_input_dims

DimsType lbann::cuTT_PermuteImpl::m_input_dims
private

Definition at line 199 of file cutt_permuteimpl.hpp.

◆ m_inv_perm

ColMajorPerm lbann::cuTT_PermuteImpl::m_inv_perm
private

Definition at line 198 of file cutt_permuteimpl.hpp.

◆ m_inv_plans

PlanMap lbann::cuTT_PermuteImpl::m_inv_plans
mutableprivate

Definition at line 204 of file cutt_permuteimpl.hpp.

◆ m_output_dims

DimsType lbann::cuTT_PermuteImpl::m_output_dims
private

Definition at line 200 of file cutt_permuteimpl.hpp.

◆ m_perm

ColMajorPerm lbann::cuTT_PermuteImpl::m_perm
private

Definition at line 197 of file cutt_permuteimpl.hpp.

◆ m_sample_fwd_plan

Plan lbann::cuTT_PermuteImpl::m_sample_fwd_plan = 0U
mutableprivate

Definition at line 205 of file cutt_permuteimpl.hpp.

◆ m_sample_inv_plan

Plan lbann::cuTT_PermuteImpl::m_sample_inv_plan = 0U
mutableprivate

Definition at line 206 of file cutt_permuteimpl.hpp.


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