8#ifndef poputil_TileMapping_hpp
9#define poputil_TileMapping_hpp
10#include "poplar/DebugContext.hpp"
11#include "poplar/Graph.hpp"
12#include "poplar/Tensor.hpp"
41std::vector<std::vector<poplar::Interval>>
43 std::vector<std::size_t> shape,
44 unsigned minElementsPerTile,
unsigned grainSize,
45 unsigned offset = 0,
bool ascendingOrder =
true);
78std::vector<std::vector<poplar::Interval>>
80 unsigned offset = 0,
bool ascendingOrder =
true);
99std::pair<poplar::Graph::TileToTensorMapping, unsigned>
118 unsigned minElementsPerTile,
unsigned grainSize);
142 unsigned minElementsPerTile,
143 unsigned grainSize,
unsigned offset,
144 bool ascendingOrder =
true);
200 bool ascendingOrder =
true);
211 const std::vector<std::size_t> &shape);
223 const std::vector<std::size_t> &shape,
240 unsigned minElementsPerTile = 0,
241 unsigned grainSize = 1);
258 unsigned minElementsPerTile = 0,
259 unsigned grainSize = 1);
261class TensorUseTrackerState;
272 std::unique_ptr<TensorUseTrackerState> st;
287 bool ascendingMappingOrder =
true);
314 ConstrainMappingToUsedTiles,
354 unsigned minElementsPerTile,
bool extendPartialUsage =
false,
376 unsigned minElementsPerTile,
377 bool extendPartialUsage =
false,
460std::pair<poplar::Tensor, unsigned>
579 bool ditherMapping =
false,
620 unsigned offset,
bool ascending);
DebugContext gathers the common external parameters of the context of an operation.
Definition: DebugContext.hpp:221
This class represents a graph program to be executed on the IPU.
Definition: Graph.hpp:52
A reference to a subset of tensor elements.
Definition: Tensor.hpp:38
Class representing device data types.
Definition: Type.hpp:42
Program that executes a sequence of programs.
Definition: Program.hpp:77
Class that tracks the usage of data on different tiles.
Definition: TileMapping.hpp:271
TensorUseTracker(TensorUseTracker &&other)
Default constructor for the TensorUseTracker class.
~TensorUseTracker()
Destructor for the TensorUserTracker class.
TensorUseTracker & operator=(const TensorUseTracker &other)
Assignment operator for the TensorUseTracker class.
TensorUseTracker(const TensorUseTracker &other)
Constructor for the TensorUseTracker class.
void add(const poplar::Graph &graph, unsigned tile, const poplar::Tensor &t)
Add a case of data usage.
void resolve(const poplar::Graph &graph, unsigned grainSize, unsigned minElementsPerTile, bool extendPartialUsage=false, TensorUseTracker::MappingMethod mappingMethod=TensorUseTracker::MappingMethod::None)
Resolve data usage for mapping.
TensorUseTracker(unsigned numTiles, unsigned startTile=0, bool ascendingMappingOrder=true)
Constructor for the TensorUseTracker class.
void mapTensorsByUse(poplar::Graph &graph, unsigned grainSize, unsigned minElementsPerTile, bool extendPartialUsage=false, TensorUseTracker::MappingMethod mappingMethod=TensorUseTracker::MappingMethod::None)
Map data according to use.
bool empty() const
Check if any cases of data usage have been registered.
MappingMethod
Definition: TileMapping.hpp:305
@ None
No mapping method used.
TensorUseTracker & operator=(TensorUseTracker &&other)
Default assignment operator for the TensorUseTracker class.
void add(TensorUseTracker other)
Add cases of data usage from another tracker.
TensorCloneMethod
Define behaviour when a Tensor is cloned.
Definition: TensorCloneMethod.hpp:13
@ PRESERVE_ORDER_UNLESS_ALIASES
Preserve the ordering of the original tensor unless it contains aliases.
@ PRESERVE_ORDER_AND_ALIASES
Preserve the ordering and aliasing within the original tensor reference.
General utility functions for building graphs.
Definition: GfloatExprUtil.hpp:23
poplar::Tensor copyToIpu(poplar::Graph &masterGraph, const poplar::Tensor &t, poplar::program::Sequence &prog, unsigned dstIPU, const poplar::DebugContext &debugContext={}, poplar::TensorCloneMethod method=poplar::TensorCloneMethod::PRESERVE_ORDER_UNLESS_ALIASES)
Move a tensor from one IPU to another.
std::pair< poplar::Tensor, unsigned > cloneAndExpandAliasing(poplar::Graph &graph, const poplar::Tensor &t, unsigned offset=0, const poplar::DebugContext &debugContext={})
Create a clone of the specified tensor on the specified graph.
poplar::Tensor cloneToGraph(poplar::Graph &srcGraph, poplar::Graph &dstGraph, const poplar::Tensor &t, const poplar::DebugContext &debugContext={}, poplar::TensorCloneMethod method=poplar::TensorCloneMethod::PRESERVE_ORDER_UNLESS_ALIASES)
Create a clone of the specified tensor on the specified graph.
unsigned invTransformTileIndex(unsigned tile, unsigned numTiles, unsigned offset, bool ascending)
Transform a tile index such that the result begins at an offset and increments or decrements.
poplar::Tensor createIpuCopy(poplar::Graph &graph, const poplar::Tensor &t, unsigned dstIpu, poplar::Tensor ©Src, poplar::Tensor ©Dst, const poplar::DebugContext &debugContext={}, poplar::TensorCloneMethod method=poplar::TensorCloneMethod::PRESERVE_ORDER_AND_ALIASES)
Prepare to move a tensor from one IPU to another.
poplar::Tensor createBroadcastOperand(poplar::Graph &graph, const poplar::Tensor &fullTensor, const poplar::Type &type, unsigned dim, bool ditherMapping=false, const poplar::DebugContext &debugContext={})
Create a simpler tensor that is mapped in the same way as another, full, tensor.
bool dimIsSplitOverIPUs(const poplar::Graph &graph, const poplar::Tensor &t, unsigned dimension)
Check if a dimension of a tensor is split over more than one IPU.
std::size_t chooseMappingOffset(std::size_t numTiles, const std::vector< std::size_t > &shape)
Choose an offset for use with tensor mapping functions using a hash of the shape provided.
void mapTensorLinearly(poplar::Graph &graph, const poplar::Tensor &t, unsigned minElementsPerTile, unsigned grainSize)
Map the specified tensor, spreading the tensor evenly over the tiles in a graph.
std::vector< std::vector< poplar::Interval > > calcLinearTileMapping(const poplar::Graph &graph, std::vector< std::size_t > shape, unsigned minElementsPerTile, unsigned grainSize, unsigned offset=0, bool ascendingOrder=true)
Calculate a tile mapping that spreads the tensor evenly over the tiles in a graph.
void mapTensorLinearlyWithOffset(poplar::Graph &graph, const poplar::Tensor &t, unsigned minElementsPerTile, unsigned grainSize, unsigned offset, bool ascendingOrder=true)
Map the specified tensor, spreading the tensor evenly over the tiles in a graph.
unsigned getTileImbalance(const poplar::Graph::TileToTensorMapping &mapping, unsigned minElementsPerTile=0, unsigned grainSize=1)
Determine how unbalanced a tensor is when mapped over tiles in a graph.
unsigned transformTileIndex(unsigned tile, unsigned numTiles, unsigned offset, bool ascending)
Transform a tile index such that the result begins at zero and increments.
bool dimIsSplitOverTiles(const poplar::Graph &graph, const poplar::Tensor &t, unsigned dimension)
Check if a dimension of a tensor is split over more than one tile.
std::pair< poplar::Graph::TileToTensorMapping, unsigned > calcLinearTileMappingAndNewOffset(const poplar::Graph &graph, const poplar::Tensor &t, unsigned offset=0)
Calculate a tile mapping that spreads the tensor evenly over the tiles in a graph.
poplar::Tensor cloneToIpu(poplar::Graph &graph, const poplar::Tensor &t, unsigned dstIPU, const poplar::DebugContext &debugContext={}, poplar::TensorCloneMethod method=poplar::TensorCloneMethod::PRESERVE_ORDER_UNLESS_ALIASES)
Create a clone of the specified tensor on the specified IPU.