Poplar and PopLibs
|
Class that tracks the usage of data on different tiles. More...
#include <TileMapping.hpp>
Public Types | |
enum class | MappingMethod { OptimizeHaloRegions , ConstrainMappingToUsedTiles , None } |
Public Member Functions | |
TensorUseTracker (unsigned numTiles, unsigned startTile=0, bool ascendingMappingOrder=true) | |
Constructor for the TensorUseTracker class. More... | |
TensorUseTracker (const TensorUseTracker &other) | |
Constructor for the TensorUseTracker class. | |
TensorUseTracker (TensorUseTracker &&other) | |
Default constructor for the TensorUseTracker class. | |
TensorUseTracker & | operator= (const TensorUseTracker &other) |
Assignment operator for the TensorUseTracker class. | |
TensorUseTracker & | operator= (TensorUseTracker &&other) |
Default assignment operator for the TensorUseTracker class. | |
~TensorUseTracker () | |
Destructor for the TensorUserTracker class. | |
void | add (const poplar::Graph &graph, unsigned tile, const poplar::Tensor &t) |
Add a case of data usage. More... | |
void | add (TensorUseTracker other) |
Add cases of data usage from another tracker. More... | |
void | resolve (const poplar::Graph &graph, unsigned grainSize, unsigned minElementsPerTile, bool extendPartialUsage=false, TensorUseTracker::MappingMethod mappingMethod=TensorUseTracker::MappingMethod::None) |
Resolve data usage for mapping. More... | |
void | mapTensorsByUse (poplar::Graph &graph, unsigned grainSize, unsigned minElementsPerTile, bool extendPartialUsage=false, TensorUseTracker::MappingMethod mappingMethod=TensorUseTracker::MappingMethod::None) |
Map data according to use. More... | |
bool | empty () const |
Check if any cases of data usage have been registered. More... | |
Class that tracks the usage of data on different tiles.
If data is broadcast to many tiles, it is sometimes efficient to map the data so that it is spread evenly amongst the tiles that use it.
This class can collect information about the use of data and then calculate a suitable tile mapping.
|
strong |
poputil::TensorUseTracker::TensorUseTracker | ( | unsigned | numTiles, |
unsigned | startTile = 0 , |
||
bool | ascendingMappingOrder = true |
||
) |
Constructor for the TensorUseTracker class.
numTiles | The number of tiles to track data use of. |
startTile | The tile to start tracking data use on. |
ascendingMappingOrder | If true, the first tile used = startTile and tiles are allocated in increasing order. If false, the first tile used = (number of device tiles -1
|
void poputil::TensorUseTracker::add | ( | const poplar::Graph & | graph, |
unsigned | tile, | ||
const poplar::Tensor & | t | ||
) |
Add a case of data usage.
graph | The Poplar graph being tracked. |
tile | The tile that the use occurs on. |
t | The tensor representing the data being used. |
void poputil::TensorUseTracker::add | ( | TensorUseTracker | other | ) |
Add cases of data usage from another tracker.
other | The TensorUseTracker to merge data usage information from. |
bool poputil::TensorUseTracker::empty | ( | ) | const |
Check if any cases of data usage have been registered.
void poputil::TensorUseTracker::mapTensorsByUse | ( | poplar::Graph & | graph, |
unsigned | grainSize, | ||
unsigned | minElementsPerTile, | ||
bool | extendPartialUsage = false , |
||
TensorUseTracker::MappingMethod | mappingMethod = TensorUseTracker::MappingMethod::None |
||
) |
Map data according to use.
This function will set the tile mapping of variable regions based on tracked data use. Variable regions with usage on multiple tiles will have their elements spread across those tiles.
graph | The Poplar graph being tracked. |
grainSize | The number of elements mapped to each tile will be an integer multiple of the grain size. |
minElementsPerTile | The minimum number of elements that must be mapped to a tile. |
extendPartialUsage | When set, partial use of tensors will be extended to cover the entire tensor, based on the usage of neighbouring regions before mapping. |
mappingMethod | Method used for mapping elements. |
void poputil::TensorUseTracker::resolve | ( | const poplar::Graph & | graph, |
unsigned | grainSize, | ||
unsigned | minElementsPerTile, | ||
bool | extendPartialUsage = false , |
||
TensorUseTracker::MappingMethod | mappingMethod = TensorUseTracker::MappingMethod::None |
||
) |
Resolve data usage for mapping.
Data used on multiple tiles will have their usage spread across those tiles.
graph | The Poplar graph being tracked. |
grainSize | The number of elements mapped to each tile will be an integer multiple of the grain size. |
minElementsPerTile | The minimum number of elements that must be mapped to a tile. |
extendPartialUsage | When set, partial usage of tensors will be extended to cover the entire tensor, based on the usage of neighbouring regions. |
mappingMethod | Method used for mapping elements. |