Poplar and PopLibs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gcl::CollectiveBalancedHostRearrangement Class Reference

This class contains functions and data necessary to rearrange tensors on the host side at runtime. More...

#include <CollectiveBalancedReorder.hpp>

Public Member Functions

 CollectiveBalancedHostRearrangement (const CollectiveBalancedHostRearrangement &)=default
 Defaulted to avoid warnings in deprecation period.
 
 CollectiveBalancedHostRearrangement (CollectiveBalancedHostRearrangement &&) noexcept=default
 Defaulted to avoid warnings in deprecation period.
 
CollectiveBalancedHostRearrangementoperator= (const CollectiveBalancedHostRearrangement &)=default
 Defaulted to avoid warnings in deprecation period. More...
 
CollectiveBalancedHostRearrangementoperator= (CollectiveBalancedHostRearrangement &&) noexcept=default
 Defaulted to avoid warnings in deprecation period. More...
 
void rearrangeForCollective (const void *in, void *out, int64_t elemByteSize) const
 Balanced reorder the tensor in a collective-friendly manner (host-side). More...
 
void rearrangeForCollective (const void *in, std::size_t inSize, void *out, std::size_t outSize, std::size_t elemByteSize) const
 Balanced reorder the tensor in a collective-friendly manner (host-side). More...
 
template<typename T >
void rearrangeForCollective (const std::vector< T > &in, std::vector< T > &out, std::size_t elemByteSize=sizeof(T)) const
 Balanced reorder the tensor in a collective-friendly manner (host-side). More...
 
void undoRearrangeForCollective (const void *in, void *out, int64_t elemByteSize) const
 Reorder tensor back into the expected IR tensor shape and order (host-side). More...
 
template<typename T >
void undoRearrangeForCollective (const std::vector< T > &in, std::vector< T > &out, std::size_t elemByteSize=sizeof(T)) const
 Reorder tensor back into the expected IR tensor shape and order (host-side). More...
 
void undoRearrangeForCollective (const void *in, std::size_t inSize, void *out, std::size_t outSize, std::size_t elemByteSize) const
 Reorder tensor back into the expected IR tensor shape and order (host-side). More...
 
size_t getNumRearrangedTensorElems () const
 Number of elements in the collective balanced (reordered) tensor. More...
 
void rearrange (const void *in, void *out, int64_t elemByteSize, bool refToGathered) const
 Host tensor rearrangement routine. More...
 
unsigned getReplicationFactor () const
 The graph's replication factor. More...
 
void setReplicationFactor (unsigned replicationFactor)
 The graph's replication factor. More...
 
std::size_t getTotalElementsPerReplica () const
 The total number for one replica's fragment. More...
 
void setTotalElementsPerReplica (std::size_t totalElementsPerReplica)
 The total number for one replica's fragment. More...
 
const std::vector< poplar::Interval > & getGatheredToRefSlices () const
 The mapping from the gathered tensor back to the reference tensor. More...
 
void setGatheredToRefSlices (std::vector< poplar::Interval > slices)
 Set the mapping from the gathered tensor back to the reference tensor. More...
 
const std::vector< uint32_t > & getElementMap () const
 Simple indices map for mapping individual elements one by one. More...
 

Public Attributes

unsigned replicationFactor = 0
 The graph's replication factor.
 
std::size_t totalElementsPerReplica = 0
 The total number for one replica's fragment.
 
std::vector< poplar::IntervalgatheredToRefSlices
 The mapping from the gathered tensor back to the reference tensor.
 
std::vector< uint32_t > elementMap
 Simple indices map for mapping individual elements one by one. More...
 

Friends

class CollectiveBalancedReorder
 Let CBR be able to update.
 

Detailed Description

This class contains functions and data necessary to rearrange tensors on the host side at runtime.

The separation is made so that we can serialize the state and restore it without having to create a poplar::Graph.

Member Function Documentation

◆ getElementMap()

const std::vector< uint32_t > & gcl::CollectiveBalancedHostRearrangement::getElementMap ( ) const

Simple indices map for mapping individual elements one by one.

It is used instead gatheredToRefSlices for short intervals.

Returns
element map

◆ getGatheredToRefSlices()

const std::vector< poplar::Interval > & gcl::CollectiveBalancedHostRearrangement::getGatheredToRefSlices ( ) const

The mapping from the gathered tensor back to the reference tensor.

Returns
mapping

◆ getNumRearrangedTensorElems()

size_t gcl::CollectiveBalancedHostRearrangement::getNumRearrangedTensorElems ( ) const

Number of elements in the collective balanced (reordered) tensor.

Returns
The number of elements.

◆ getReplicationFactor()

unsigned gcl::CollectiveBalancedHostRearrangement::getReplicationFactor ( ) const

The graph's replication factor.

Returns
replication factor

◆ getTotalElementsPerReplica()

std::size_t gcl::CollectiveBalancedHostRearrangement::getTotalElementsPerReplica ( ) const

The total number for one replica's fragment.

Returns
number of elements per replica

◆ operator=() [1/2]

CollectiveBalancedHostRearrangement & gcl::CollectiveBalancedHostRearrangement::operator= ( CollectiveBalancedHostRearrangement &&  )
defaultnoexcept

Defaulted to avoid warnings in deprecation period.

Returns
The CollectiveBalancedHostRearrangement that is assigned to.

◆ operator=() [2/2]

CollectiveBalancedHostRearrangement & gcl::CollectiveBalancedHostRearrangement::operator= ( const CollectiveBalancedHostRearrangement )
default

Defaulted to avoid warnings in deprecation period.

Returns
The CollectiveBalancedHostRearrangement that is assigned to.

◆ rearrange()

void gcl::CollectiveBalancedHostRearrangement::rearrange ( const void *  in,
void *  out,
int64_t  elemByteSize,
bool  refToGathered 
) const

Host tensor rearrangement routine.

Parameters
inPointer to the input buffer.
outPointer to the output buffer.
elemByteSizeThe byte size of the elements.
refToGatheredWhether to rearrange from reference to gathered or the other way.

◆ rearrangeForCollective() [1/3]

template<typename T >
void gcl::CollectiveBalancedHostRearrangement::rearrangeForCollective ( const std::vector< T > &  in,
std::vector< T > &  out,
std::size_t  elemByteSize = sizeof(T) 
) const
inline

Balanced reorder the tensor in a collective-friendly manner (host-side).

Parameters
inInput buffer.
outOutput buffer.
elemByteSizeThe byte size of the elements.

◆ rearrangeForCollective() [2/3]

void gcl::CollectiveBalancedHostRearrangement::rearrangeForCollective ( const void *  in,
std::size_t  inSize,
void *  out,
std::size_t  outSize,
std::size_t  elemByteSize 
) const

Balanced reorder the tensor in a collective-friendly manner (host-side).

Parameters
inPointer to the input buffer.
inSizeThe size of the in buffer in bytes.
outPointer to the output buffer.
outSizeThe size of the out buffer in bytes.
elemByteSizeThe byte size of the elements.

◆ rearrangeForCollective() [3/3]

void gcl::CollectiveBalancedHostRearrangement::rearrangeForCollective ( const void *  in,
void *  out,
int64_t  elemByteSize 
) const

Balanced reorder the tensor in a collective-friendly manner (host-side).

Parameters
inPointer to the input buffer.
outPointer to the output buffer.
elemByteSizeThe byte size of the elements.

◆ setGatheredToRefSlices()

void gcl::CollectiveBalancedHostRearrangement::setGatheredToRefSlices ( std::vector< poplar::Interval slices)

Set the mapping from the gathered tensor back to the reference tensor.

Parameters
slices

◆ setReplicationFactor()

void gcl::CollectiveBalancedHostRearrangement::setReplicationFactor ( unsigned  replicationFactor)

The graph's replication factor.

Parameters
replicationFactor

◆ setTotalElementsPerReplica()

void gcl::CollectiveBalancedHostRearrangement::setTotalElementsPerReplica ( std::size_t  totalElementsPerReplica)

The total number for one replica's fragment.

Parameters
totalElementsPerReplica

◆ undoRearrangeForCollective() [1/3]

template<typename T >
void gcl::CollectiveBalancedHostRearrangement::undoRearrangeForCollective ( const std::vector< T > &  in,
std::vector< T > &  out,
std::size_t  elemByteSize = sizeof(T) 
) const
inline

Reorder tensor back into the expected IR tensor shape and order (host-side).

Parameters
inInput buffer.
outOutput buffer.
elemByteSizeThe byte size of the elements.

◆ undoRearrangeForCollective() [2/3]

void gcl::CollectiveBalancedHostRearrangement::undoRearrangeForCollective ( const void *  in,
std::size_t  inSize,
void *  out,
std::size_t  outSize,
std::size_t  elemByteSize 
) const

Reorder tensor back into the expected IR tensor shape and order (host-side).

Parameters
inPointer to the input buffer.
inSizeThe size of the in buffer in bytes.
outPointer to the output buffer.
outSizeThe size of the out buffer in bytes.
elemByteSizeThe byte size of the elements.

◆ undoRearrangeForCollective() [3/3]

void gcl::CollectiveBalancedHostRearrangement::undoRearrangeForCollective ( const void *  in,
void *  out,
int64_t  elemByteSize 
) const

Reorder tensor back into the expected IR tensor shape and order (host-side).

Parameters
inPointer to the input buffer.
outPointer to the output buffer.
elemByteSizeThe byte size of the elements.

Member Data Documentation

◆ elementMap

std::vector<uint32_t> gcl::CollectiveBalancedHostRearrangement::elementMap

Simple indices map for mapping individual elements one by one.

It is used instead gatheredToRefSlices for short intervals.


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