Poplar and PopLibs
popops Namespace Reference

Common functions, such as elementwise and reductions. More...

Classes

struct  GatherParams
 Defines the parameters to a gather operation. More...
 
struct  IndicesAndTensor
 The pair of values returned by createHostSliceableTensor(). More...
 
struct  ReduceParams
 Stores parameters for the reduce operation, as well as the basic operation being performed (for example, add or mul). More...
 
struct  SingleReduceOp
 The parameterisation of the inputs to a single reduction for the reduceMany() function. More...
 
class  SlicePlan
 An object representing a plan that describes how to implement a slice or update. More...
 
struct  TopKParams
 Parameters for topK* APIs. More...
 

Enumerations

enum class  Operation { }
 Type of operation to use in a reduction. More...
 
enum class  SortOrder { NONE , ASCENDING , DESCENDING }
 Defines a required order for sorting operations. More...
 

Functions

poplar::Tensor allTrue (poplar::Graph &graph, poplar::Tensor A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Given a boolean tensor, compute the logical AND of all its elements. More...
 
poplar::Tensor cast (poplar::Graph &graph, const poplar::Tensor &src, const poplar::Type &dstType, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Cast elements of the specified src tensor to dstType, returning the result as a new tensor. More...
 
poplar::Tensor cast (poplar::Graph &graph, const poplar::Tensor &src, const poplar::Type &dstType, const poplar::Tensor &metadata, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Cast elements of the specified src tensor to dstType, returning the result as a new tensor. More...
 
poplar::program::Program cast (poplar::Graph &graph, poplar::Tensor src, poplar::Tensor dst, const poplar::DebugContext &debugContext={})
 Create a program to copy tensor casting between types (for example, half->float). More...
 
void cast (poplar::Graph &graph, poplar::Tensor src, poplar::Tensor dst, poplar::ComputeSet cs)
 Create vertices to copy element wise from the src tensor to the dst tensor casting between types (for example, half->float). More...
 
poplar::Tensor cast (poplar::Graph &graph, poplar::Tensor src, const poplar::Type &dstType, poplar::ComputeSet cs, const poplar::DebugContext &debugContext={})
 Create vertices to cast elements of the specified src tensor to dstType, returning the result as a new tensor. More...
 
poplar::Tensor cast (poplar::Graph &graph, poplar::Tensor src, const poplar::Type &dstType, const poplar::Tensor &metadata, poplar::ComputeSet cs, const poplar::DebugContext &debugContext={})
 Create vertices to cast elements of the specified src tensor to dstType, returning the result as a new tensor. More...
 
poplar::Tensor checkAccuracyWhenCast (poplar::Graph &graph, const poplar::Tensor &input, poplar::Type outputType, double tolerance, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Helper function which checks the relative error in the tensor input when casting it to type outputType. More...
 
poplar::Tensor createSliceableTensor (poplar::Graph &graph, const poplar::Type &type, const std::vector< size_t > &shape, const std::vector< size_t > &dims, const std::vector< size_t > &sizes, std::size_t minGrainSize=0, const poplar::DebugContext &debugContext={})
 Create and map a tensor to be sliced/updated efficiently. More...
 
poplar::Tensor createSliceableTensor (poplar::Graph &graph, const poplar::Type &type, const std::vector< size_t > &shape, const std::vector< size_t > &dims, const std::vector< size_t > &sizes, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Create and map a tensor to be sliced/updated efficiently. More...
 
poplar::Tensor createGroupedSliceableTensor (poplar::Graph &graph, const poplar::Type &type, const std::size_t groupSize, const std::vector< std::size_t > &shape, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Create and map a tensor with a group dimension to be sliced/updated efficiently. More...
 
poplar::Tensor createSliceTensor (poplar::Graph &graph, const poplar::Tensor &t, const std::vector< size_t > &dims, const std::vector< size_t > &sizes, std::size_t numIndices, const poplar::DebugContext &debugContext={})
 Create and map a tensor that is used as a result of slicing, or as an input to an update. More...
 
poplar::Tensor createSliceTensor (poplar::Graph &graph, const poplar::Type &type, const std::vector< std::size_t > &shape, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, std::size_t numIndices, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Create and map a tensor that is used as a result of slicing, or as an input to an update. More...
 
poplar::Tensor createGroupedSliceTensor (poplar::Graph &graph, const poplar::Type &type, const std::size_t groupSize, const std::vector< std::size_t > &shape, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, const std::size_t numIndices, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Create and map a tensor with a group dimension that is used as a result of slicing, or as an input to an update. More...
 
poplar::Tensor createIndicesTensor (poplar::Graph &graph, const std::vector< std::size_t > &dims, std::size_t numIndices, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Create and map a tensor to contain indices for slicing or updating a tensor efficiently. More...
 
poplar::Tensor createGroupedIndicesTensor (poplar::Graph &graph, const std::size_t groupSize, const std::vector< std::size_t > &dims, const std::size_t numIndices, const SlicePlan &plan, const poplar::OptionFlags &, const poplar::DebugContext &debugContext={})
 Create and map a tensor with a group dimension to contain indices for slicing or updating a tensor efficiently. More...
 
poplar::Tensor createSliceableTensorFromSlice (poplar::Graph &graph, const poplar::Tensor &s, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &numSlices, const poplar::DebugContext &debugContext={})
 Create and map a tensor to be sliced/updated. More...
 
poplar::Tensor dynamicSlice (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &offset, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Slice a tensor based on offsets specified by a tensor. More...
 
void dynamicSliceWithOutput (poplar::Graph &graph, const poplar::Tensor &output, const poplar::Tensor &t, const poplar::Tensor &offset, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Slice a tensor based on offsets specified by a tensor. More...
 
poplar::Graph::TileToTensorMapping getSliceMapping (poplar::Graph &graph, const poplar::Tensor &t, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes)
 Get the tile mapping for a slice of a tensor. More...
 
void dynamicUpdate (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &s, const poplar::Tensor &offset, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Update a subtensor at offsets read from a tensor. More...
 
poplar::Tensor multiSlice (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &offsets, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Take multiple slices from a base tensor. More...
 
poplar::Tensor groupedMultiSlice (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &offsets, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Take multiple slices from a base tensor where the base tensor and the offsets tensor have the group dimension as the first dimension. More...
 
poplar::Tensor multiSlice (poplar::Graph &graph, const poplar::Tensor &t, poplar::ArrayRef< unsigned > offsets, std::size_t dim, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Take multiple slices from a base tensor. More...
 
void multiUpdate (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &s, const poplar::Tensor &offsets, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Update multiple slices in a tensor. More...
 
void groupedMultiUpdate (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &s, const poplar::Tensor &offsets, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Update multiple slices in a tensor with a group dimension. More...
 
void multiUpdateAdd (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &s, const poplar::Tensor &offsets, const poplar::Tensor &scale, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Accumulate multiple slices in a tensor. More...
 
void groupedMultiUpdateAdd (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &s, const poplar::Tensor &offsets, const poplar::Tensor &scale, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Accumulate multiple slices in a tensor where the first dimension of the tensors t, s and offsets is the group dimension. More...
 
void multiUpdateAdd (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &s, poplar::ArrayRef< unsigned > offsets, const poplar::Tensor &scale, std::size_t dim, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Accumulate multiple slices in a tensor. More...
 
void multiUpdateMax (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &s, const poplar::Tensor &offsets, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Find maximum over multiple slices in a tensor. More...
 
void groupedMultiUpdateMax (poplar::Graph &graph, const poplar::Tensor &t, const poplar::Tensor &s, const poplar::Tensor &offsets, const std::vector< std::size_t > &dims, const std::vector< std::size_t > &sizes, poplar::program::Sequence &prog, const SlicePlan &plan, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
 Find maximum over multiple slices in a tensor with a group dimension. More...
 
void outputGeneratedCodelet (const poplar::Target &target, const expr::Expr &expr, const std::vector< poplar::Tensor > &ts, const poplar::OptionFlags &options, std::ostream &os)
 Writes the generated codelet for the given expr and ts to os. More...
 
poplar::Tensor asin (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the arc-sine of each element in A. More...
 
void asinInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of asin().
 
void asinWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of asin() to the given output tensor.
 
poplar::Tensor bitwiseNot (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the bitwise NOT operation for each element in A. More...
 
void bitwiseNotInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of bitwiseNot().
 
void bitwiseNotWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of bitwiseNot() to the given output tensor.
 
poplar::Tensor cbrt (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the cube-root for each element in A. More...
 
void cbrtInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of cbrt().
 
void cbrtWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of cbrt() to the given output tensor.
 
poplar::Tensor geluErf (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute (1 + erf(A/sqrt(2))) * A / 2 where all the operations are element-wise, and erf is the error function. More...
 
void geluErfInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of geluErf().
 
void geluErfWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of geluErf() to the given output tensor.
 
poplar::Tensor ceil (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the ceiling of each element in A. More...
 
void ceilInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of ceil().
 
void ceilWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of ceil() to the given output tensor.
 
poplar::Tensor countLeadingZeros (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the number of binary leading zeros of each element in A. More...
 
void countLeadingZerosInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of countLeadingZeros().
 
void countLeadingZerosWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of countLeadingZeros() to the given output tensor.
 
poplar::Tensor cos (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the cosine of each element in A. More...
 
void cosInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of cos().
 
void cosWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of cos() to the given output tensor.
 
poplar::Tensor erf (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the error function of each element in A. More...
 
void erfInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of erf().
 
void erfWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of erf() to the given output tensor.
 
poplar::Tensor exp (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the exponential of each element in A. More...
 
void expInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of exp().
 
void expWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of exp() to the given output tensor.
 
poplar::Tensor expm1 (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the exponential of each element in A minus one. More...
 
void expm1InPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of expm1().
 
void expm1WithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of expm1() to the given output tensor.
 
poplar::Tensor floor (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the floor of each element in A. More...
 
void floorInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of floor().
 
void floorWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of floor() to the given output tensor.
 
poplar::Tensor inv (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the inverse of each element in A. More...
 
void invInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of inv().
 
void invWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of inv() to the given output tensor.
 
poplar::Tensor log (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the log base-e of each element in A. More...
 
void logInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of log().
 
void logWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of log() to the given output tensor.
 
poplar::Tensor log1p (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the log base-e of each element in A plus one. More...
 
void log1pInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of log1p().
 
void log1pWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of log1p() to the given output tensor.
 
poplar::Tensor logicalNot (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the logical NOT of each element in A. More...
 
void logicalNotInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of logicalNot().
 
void logicalNotWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of logicalNot() to the given output tensor.
 
poplar::Tensor neg (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the negation of each element in A. More...
 
void negInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of neg().
 
void negWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of neg() to the given output tensor.
 
poplar::Tensor popcount (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the number of 1 bits in each element of A. More...
 
void popcountInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of popcount().
 
void popcountWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of popcount() to the given output tensor.
 
poplar::Tensor signum (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the signum of each element in A. More...
 
void signumInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of signum().
 
void signumWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of signum() to the given output tensor.
 
poplar::Tensor sin (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the sine of each element in A. More...
 
void sinInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of sin().
 
void sinWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of sin() to the given output tensor.
 
poplar::Tensor tan (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the tangent of each element in A. More...
 
void tanInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of tan().
 
void tanWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of tan() to the given output tensor.
 
poplar::Tensor tanh (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the hyperbolic tangent of each element in A. More...
 
void tanhInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of tanh().
 
void tanhWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of tanh() to the given output tensor.
 
poplar::Tensor round (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Round each element in A. More...
 
void roundInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of round().
 
void roundWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of round() to the given output tensor.
 
poplar::Tensor sqrt (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the square-root for each element in A. More...
 
void sqrtInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of sqrt().
 
void sqrtWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of sqrt() to the given output tensor.
 
poplar::Tensor square (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the square for each element in A. More...
 
void squareInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of square().
 
void squareWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of square() to the given output tensor.
 
poplar::Tensor sigmoid (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the sigmoid (logistic) function for each element in A. More...
 
void sigmoidInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of sigmoid().
 
void sigmoidWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of sigmoid() to the given output tensor.
 
poplar::Tensor rsqrt (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the reciprocal square root for each element in A. More...
 
void rsqrtInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of rsqrt().
 
void rsqrtWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of rsqrt() to the given output tensor.
 
poplar::Tensor isFinite (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Check if each element in A is finite. More...
 
void isFiniteWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of isFinite() to the given output tensor.
 
poplar::Tensor select (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &C, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Populate the returned tensor with elements from A or B depending on the corresponding element of C. More...
 
void selectInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &C, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of select().
 
void selectWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &C, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of select() to the given output tensor.
 
poplar::Tensor clamp (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &C, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Populate the returned tensor with elements from A but clamp them such that each element is greater than or equal to the corresponding element in B and less than or equal to the corresponding element in C. More...
 
void clampInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &C, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of clamp().
 
void clampWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &C, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of clamp() to the given output tensor.
 
poplar::Tensor createOutputForElementWiseOp (poplar::Graph &graph, const std::vector< poplar::Tensor > &inputs, const poplar::Type &outputType, const poplar::DebugContext &debugContext={})
 Create a tensor for use as the output of an element-wise operation (operation with no dependency between more than one element of the output and any given element of any input tensor). More...
 
void encodeOneHot (poplar::Graph &graph, const poplar::Tensor &indices, const poplar::Tensor &encoded, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Encode a given set of indices as a set of one-hot vectors per-index with a hot element at that index. More...
 
void encodeOneHot (poplar::Graph &graph, const poplar::Tensor &indices, const poplar::Tensor &encoded, poplar::program::Sequence &prog, const poplar::Tensor &on, const poplar::Tensor &off, const poplar::DebugContext &debugContext={})
 Encode a given set of indices as a set of one-hot vectors per-index with a hot element at that index. More...
 
void iota (poplar::Graph &graph, const poplar::Tensor &t, unsigned startInteger, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Fill a tensor with a right-open range of unsigned integers: [startInteger, startInteger + length), where length is the number of elements in the mapped 1-D output tensor t. More...
 
void iota (poplar::Graph &graph, const poplar::Tensor &t, int startInteger, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Fill a tensor with a right-open range of signed integers: [startInteger, startInteger + length), where length is the number of elements in the mapped 1-D output tensor t. More...
 
template<typename FillValueType >
void fill (poplar::Graph &graph, poplar::Tensor t, const std::vector< poplar::Interval > &tileRegions, unsigned tile, poplar::ComputeSet fillCS, FillValueType fillValue)
 Appends vertices to fillCS which fills elements in tileRegions of t which reside on tile tile. More...
 
template<typename FillValueType >
void fill (poplar::Graph &graph, const poplar::Tensor &t, unsigned tile, poplar::ComputeSet fillCS, FillValueType fillValue)
 Appends vertices to fillCS which fills all elements of t which reside on tile tile. More...
 
template<typename FillValueType >
void fill (poplar::Graph &graph, const poplar::Tensor &t, const std::vector< std::vector< poplar::Interval > > &mapping, poplar::ComputeSet fillCS, FillValueType fillValue)
 Appends vertices to fillCS which fills elements in mapping of t which reside on tiles represented with mapping. More...
 
template<typename FillValueType >
void fill (poplar::Graph &graph, const poplar::Tensor &t, poplar::program::Sequence &prog, FillValueType fillValue, const poplar::DebugContext &debugContext={})
 Appends programs to prog which fills all elements of the tensor t with a value of fillValue. More...
 
poplar::Tensor createGatherInput (poplar::Graph &graph, const poplar::Type &type, const std::vector< std::size_t > &operandShape, unsigned axis, GatherParams params={}, const poplar::DebugContext &debugContext={})
 Create the input of the gather with only a single gather axis. More...
 
poplar::Tensor gather (poplar::Graph &graph, const poplar::Tensor &input, const poplar::Tensor &indices, unsigned axis, poplar::program::Sequence &prog, GatherParams params, const poplar::DebugContext &debugContext={})
 The gather operation stitches together several slices (each slice at a potentially different runtime offset) of an input tensor. More...
 
poplar::Tensor createGatherInput (poplar::Graph &graph, const poplar::Type &type, const std::vector< std::size_t > &inputShape, const std::vector< std::size_t > &sliceSizes, std::vector< unsigned > startIndexMap, const poplar::DebugContext &debugContext={})
 Create the input of the gather given a start index map. More...
 
poplar::Tensor gather (poplar::Graph &graph, const poplar::Tensor &input, const poplar::Tensor &indices, std::size_t indexVectorDim, const std::vector< std::size_t > &offsetDims, const std::vector< std::size_t > &sliceSizes, const std::vector< std::size_t > &collapsedSliceDims, const std::vector< unsigned > &startIndexMap, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 The gather operation stitches together several slices (each slice at a potentially different runtime offset) of an input tensor. More...
 
poplar::Tensor histogram (poplar::Graph &graph, const poplar::Tensor &input, const poplar::Tensor &levels, bool absoluteOfInput, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Gather a histogram representing the statistics of the input tensor. More...
 
void histogram (poplar::Graph &graph, const poplar::Tensor &input, poplar::Tensor &output, bool updateOutput, const poplar::Tensor &levels, bool absoluteOfInput, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Fill a tensor with a histogram representing the statistics of the input tensor. More...
 
IndicesAndTensor createHostSliceableTensor (poplar::Graph &graph, const poplar::Type &type, const std::vector< size_t > &shape, const bool isRead, const poplar::DebugContext &debugContext={})
 Create a Tensor that is well laid out for a host exchange copy and at the same time create the index tensor for the copy. More...
 
poplar::Tensor createHostTransferableTensor (poplar::Graph &graph, const poplar::Type &type, const std::vector< size_t > &shape, bool isRead, const poplar::DebugContext &debugContext={})
 Create a tensor that is well laid out for a host exchange copy. More...
 
poplar::program::Sequence countedLoop (poplar::Graph &graph, std::size_t begin, std::size_t end, size_t step, const CountedLoopBodyType &body, const poplar::DebugContext &debugContext={})
 Create a loop program with constant initial count, increment and end value. More...
 
poplar::program::Sequence countedLoop (poplar::Graph &graph, std::size_t count, const CountedLoopBodyType &body, const poplar::DebugContext &debugContext={})
 Create a loop program which executes count times. More...
 
poplar::program::Sequence countedForLoop (poplar::Graph &graph, const poplar::Tensor &count, int initialCount, const poplar::Tensor &countLimit, int countStep, const poplar::program::Program &body, const poplar::DebugContext &debugContext={})
 Create a for-loop program with constant initial count and increment, and a tensor as the end value. More...
 
poplar::program::Sequence countedForLoop (poplar::Graph &graph, int initialCount, const poplar::Tensor &countLimit, int countStep, const poplar::program::Program &body, const poplar::DebugContext &debugContext={})
 Create a for loop program with constant initial count and increment and a tensor as the end value. More...
 
poplar::Tensor hasNaN (poplar::Graph &graph, const poplar::Tensor &src, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Test for NaN values in a tensor. More...
 
poplar::Tensor hasNaNOrInf (poplar::Graph &graph, const poplar::Tensor &src, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Test for NaN or Inf values in a tensor. More...
 
poplar::Tensor createNormaliseImageInput (poplar::Graph &graph, const poplar::Type &type, const poplar::ArrayRef< std::size_t > shape, const poplar::DebugContext &debugContext={})
 Add a tensor for a 3-channel image suitable for padding to 4 channels. More...
 
poplar::Tensor normaliseImage (poplar::Graph &graph, poplar::program::Sequence &seq, poplar::Tensor tIn, float inScale, poplar::Tensor offsets, poplar::Tensor scales, const poplar::DebugContext &debugContext={})
 Pad a tensor to have 4 channel dimensions. More...
 
std::istream & operator>> (std::istream &is, Operation &op)
 Parse token from input stream is to op. More...
 
std::ostream & operator<< (std::ostream &os, const Operation &op)
 Write op to output stream os. More...
 
poplar::Tensor pad (const poplar::Tensor &t, const std::vector< std::ptrdiff_t > &paddingLower, const std::vector< std::ptrdiff_t > &paddingUpper, padding::Type type)
 Return a tensor with numpy-style padding added. More...
 
poplar::Tensor pad (const poplar::Tensor &t, std::ptrdiff_t paddingLower, std::ptrdiff_t paddingUpper, unsigned dim, padding::Type type)
 Return a tensor with numpy-style padding added to one dimension. More...
 
poplar::Tensor reduce (poplar::Graph &graph, const poplar::Tensor &in, const poplar::Type &outType, const std::vector< std::size_t > &dims, ReduceParams params, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Apply a reduction operation to a tensor. More...
 
poplar::Tensor reduce (poplar::Graph &graph, const poplar::Tensor &in, const std::vector< std::size_t > &dims, ReduceParams params, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Apply a reduction operation to a tensor. More...
 
void reduceWithOutput (poplar::Graph &graph, const poplar::Tensor &in, const poplar::Tensor &out, const std::vector< std::size_t > &dims, ReduceParams params, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Apply a reduction operation to a tensor. More...
 
void reduceMany (poplar::Graph &graph, const std::vector< SingleReduceOp > &reductions, std::vector< poplar::Tensor > &outputs, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Perform many reductions (in parallel if possible). More...
 
void scaledAddTo (poplar::Graph &graph, poplar::Tensor A, poplar::Tensor B, float scaleB, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Add the elements of one tensor multiplied by a scalar to another tensor. More...
 
void scaledAddTo (poplar::Graph &graph, poplar::Tensor A, poplar::Tensor B, poplar::Tensor scaleB, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Add the elements of one tensor each multiplied by a (scalar) tensor to another tensor. More...
 
void scaledSubtractFrom (poplar::Graph &graph, poplar::Tensor A, poplar::Tensor B, float scaleB, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Subtract the elements of one tensor multiplied by a scalar from another tensor. More...
 
void scaledSubtractFrom (poplar::Graph &graph, poplar::Tensor A, poplar::Tensor B, poplar::Tensor scaleB, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Subtract the elements of one tensor each multiplied by a (scalar) tensor from another tensor. More...
 
void scaledAddTo (poplar::Graph &graph, poplar::Tensor A, poplar::Tensor scaleA, poplar::Tensor B, poplar::Tensor scaleB, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Scale the elements of one tensor and add the scaled elements of another tensor to it. More...
 
void scaledAddTo (poplar::Graph &graph, poplar::Tensor A, poplar::Tensor scaleA, poplar::Tensor B, poplar::Tensor scaleB, poplar::program::Sequence &prog, const ScaledAddSpecialisation speciality, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Scale the elements of one tensor and add the scaled elements of another tensor to it. More...
 
void scaledAddTo (poplar::Graph &graph, poplar::Tensor A, float scaleA, poplar::Tensor B, float scaleB, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Scale the elements of one tensor and add the scaled elements of another tensor to it. More...
 
void scaledAddTo (poplar::Graph &graph, poplar::Tensor A, float scaleA, poplar::Tensor B, float scaleB, poplar::program::Sequence &prog, const ScaledAddSpecialisation speciality, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Scale the elements of one tensor and add the scaled elements of another tensor to it. More...
 
void scaledSubtractFrom (poplar::Graph &graph, poplar::Tensor A, poplar::Tensor scaleA, poplar::Tensor B, poplar::Tensor scaleB, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Scale the elements of one tensor and subtract the scaled elements of another tensor to it. More...
 
void scaledSubtractFrom (poplar::Graph &graph, poplar::Tensor A, float scaleA, poplar::Tensor B, float scaleB, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Scale the elements of one tensor and subtract the scaled elements of another tensor to it. More...
 
void scatter (poplar::Graph &graph, const poplar::Tensor &operand, const poplar::Tensor &indices, const poplar::Tensor &updates, std::size_t indexVectorDim, std::vector< unsigned > updateWindowDims, std::vector< std::size_t > insertWindowDims, std::vector< unsigned > scatterDimsToOperandDims, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 The scatter operation generates a result which is the value of the input array operand, with several slices (at indices specified by indices) updated with the values in updates. More...
 
void scatter (poplar::Graph &graph, const poplar::Tensor &operand, const poplar::Tensor &indices, const poplar::Tensor &updates, std::size_t indexVectorDim, std::vector< unsigned > updateWindowDims, std::vector< std::size_t > insertWindowDims, std::vector< unsigned > scatterDimsToOperandDims, UpdateComputationFunc &updateComputation, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Similar to the above scatter(), but allows for a user defined update computation. More...
 
poplar::Tensor selectScalarFromRows (poplar::Graph &graph, const poplar::Tensor &params, const poplar::Tensor &indices, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 For each row in the 2D tensor params, select a single scalar value. More...
 
void sequenceSlice (poplar::Graph &graph, const poplar::Tensor &tIn, const poplar::Tensor &tOut, const poplar::Tensor &tN, const poplar::Tensor &tInOffset, const poplar::Tensor &tOutOffset, bool zeroUnused, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Slice a 2d tensor based on offsets specified by a tensor. More...
 
poplar::Tensor sort (poplar::Graph &graph, const poplar::Tensor &t, unsigned dim, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 
void sortInPlace (poplar::Graph &graph, const poplar::Tensor &t, unsigned dim, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 
poplar::Tensor sortKeyValue (poplar::Graph &graph, const poplar::Tensor &k, const poplar::Tensor &v, unsigned dim, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 
void sortKeyValueInPlace (poplar::Graph &graph, const poplar::Tensor &k, const poplar::Tensor &v, unsigned dim, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 
poplar::Tensor createTopKInput (poplar::Graph &graph, const poplar::Type &type, const std::vector< std::size_t > &shape, const TopKParams &params, const poplar::DebugContext &debugContext={})
 Create an return a new tensor laid out optimally to be used as an input to a topK operation with the given parameters. More...
 
poplar::Tensor topK (poplar::Graph &graph, poplar::program::Sequence &prog, const poplar::Tensor &t, const TopKParams &params, const poplar::DebugContext &debugContext={})
 Return the top k values in the innermost dimension of a tensor. More...
 
std::pair< poplar::Tensor, poplar::TensortopKKeyValue (poplar::Graph &graph, poplar::program::Sequence &prog, const poplar::Tensor &keys, const poplar::Tensor &values, const TopKParams &params, const poplar::DebugContext &debugContext={})
 Return the top k values in the innermost dimension of a tensor along with the permutation of another tensor with respect to the values. More...
 
std::pair< poplar::Tensor, poplar::TensortopKWithPermutation (poplar::Graph &graph, poplar::program::Sequence &prog, const poplar::Tensor &t, const TopKParams &params, const poplar::DebugContext &debugContext={})
 Return the top k values in the innermost dimension of a tensor along with the indices of those values in the input tensor in the innermost dimension. More...
 
void updateScalarInRows (poplar::Graph &graph, const poplar::Tensor &params, const poplar::Tensor &indices, poplar::program::Sequence &program, const poplar::DebugContext &debugContext={})
 Update in-place one scalar per row of the tensor params. More...
 
void zero (poplar::Graph &graph, poplar::Tensor t, const std::vector< poplar::Interval > &tileRegions, unsigned tile, poplar::ComputeSet zeroCS)
 Append vertices to compute set zeroCS which zeroes elements in tileRegions of tensor t which reside on tile. More...
 
void zero (poplar::Graph &graph, const poplar::Tensor &t, unsigned tile, poplar::ComputeSet zeroCS)
 Append vertices to compute set zeroCS which zeroes all elements of tensor t which reside on tile. More...
 
void zero (poplar::Graph &graph, const poplar::Tensor &t, const std::vector< std::vector< poplar::Interval > > &mapping, poplar::ComputeSet zeroCS)
 Append vertices to compute set zeroCS which zeroes elements in mapping of tensor t which reside on tiles represented with mapping. More...
 
void zero (poplar::Graph &graph, const poplar::Tensor &t, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={})
 Append programs to program sequence prog which zeroes all elements of tensor t. More...
 
poplar::Tensor varianceToInvStdDev (poplar::Graph &graph, const poplar::Tensor &src, const poplar::Tensor &epsilon, poplar::program::Sequence &prog, const poplar::Type dstType=poplar::HALF, const poplar::DebugContext &debugContext={})
 Convert variance to inverse standard deviation. More...
 
poplar::Tensor invStdDevToVariance (poplar::Graph &graph, const poplar::Tensor &src, const poplar::Tensor &epsilon, poplar::program::Sequence &prog, const poplar::Type dstType=poplar::FLOAT, const poplar::DebugContext &debugContext={})
 Convert inverse standard deviation to variance. More...
 
poplar::Tensor map (poplar::Graph &graph, const expr::Expr &expr, const std::vector< poplar::Tensor > &ts, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Map an expression across tensors. More...
 
void mapInPlace (poplar::Graph &graph, const expr::Expr &expr, const std::vector< poplar::Tensor > &ts, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensors with the result of map().
 
void mapWithOutput (poplar::Graph &graph, const expr::Expr &expr, const std::vector< poplar::Tensor > &ts, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of map() to the given output tensor.
 
poplar::Tensor abs (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the absolute value of each element in A. More...
 
void absInPlace (poplar::Graph &graph, const poplar::Tensor &A, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of abs().
 
void absWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of abs() to the given output tensor.
 
template<typename constType >
void checkTypes (poplar::Type elementType, constType)
 Check that the host compile-time type constType is compatible with the run-time IPU type elementType. More...
 
poplar::Tensor add (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Add each element in A to the corresponding element in B. More...
 
void addInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of add().
 
void addWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of add() to the given output tensor.
 
poplar::Tensor atan2 (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the two argument arctangent of each element in A with the corresponding element in B. More...
 
void atan2InPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of atan2().
 
void atan2WithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of atan2() to the given output tensor.
 
poplar::Tensor bitwiseAnd (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the bitwise AND of each element in A with the corresponding element in B. More...
 
void bitwiseAndInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of bitwiseAnd().
 
void bitwiseAndWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of bitwiseAnd() to the given output tensor.
 
poplar::Tensor bitwiseOr (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the bitwise OR of each element in A with the corresponding element in B. More...
 
void bitwiseOrInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of bitwiseOr().
 
void bitwiseOrWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of bitwiseOr() to the given output tensor.
 
poplar::Tensor bitwiseXor (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the bitwise XOR of each element in A with the corresponding element in B. More...
 
void bitwiseXorInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of bitwiseXor().
 
void bitwiseXorWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of bitwiseXor() to the given output tensor.
 
poplar::Tensor bitwiseXnor (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the bitwise XNOR of each element in A with the corresponding element in B. More...
 
void bitwiseXnorInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of bitwiseXnor().
 
void bitwiseXnorWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of bitwiseXnor() to the given output tensor.
 
poplar::Tensor div (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Divide each element in A by the corresponding element in B. More...
 
void divInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of div().
 
void divWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of div() to the given output tensor.
 
poplar::Tensor eq (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Check if each element in A is equal to the corresponding element in B. More...
 
void eqInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of eq().
 
void eqWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of eq() to the given output tensor.
 
poplar::Tensor gteq (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Check if each element in A is greater than or equal to the corresponding element in B. More...
 
void gteqInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of gteq().
 
void gteqWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of gteq() to the given output tensor.
 
poplar::Tensor gt (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Check if each element in A is greater than the corresponding element in B. More...
 
void gtInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of gt().
 
void gtWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of gt() to the given output tensor.
 
poplar::Tensor invStdDevToVariance (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Convert the inverse standard deviation to variance. More...
 
void invStdDevToVarianceInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of invStdDevToVariance().
 
void invStdDevToVarianceWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of invStdDevToVariance() to the given output tensor.
 
poplar::Tensor lteq (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Check if each element in A is less than or equal to the corresponding element in B. More...
 
void lteqInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of lteq().
 
void lteqWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of lteq() to the given output tensor.
 
poplar::Tensor logicalAnd (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the logical AND (&&) of each element in A with the corresponding element in B. More...
 
void logicalAndInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of logicalAnd().
 
void logicalAndWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of logicalAnd() to the given output tensor.
 
poplar::Tensor logicalOr (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the logical OR (||) of each element in A with the corresponding element in B. More...
 
void logicalOrInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of logicalOr().
 
void logicalOrWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of logicalOr() to the given output tensor.
 
poplar::Tensor lt (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Check if each element in A is less than the corresponding element in B. More...
 
void ltInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of lt().
 
void ltWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of lt() to the given output tensor.
 
poplar::Tensor max (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the maximum of each element in A with the corresponding element in B. More...
 
void maxInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of max().
 
void maxWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of max() to the given output tensor.
 
poplar::Tensor min (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the minimum of each element in A with the corresponding element in B. More...
 
void minInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of min().
 
void minWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of min() to the given output tensor.
 
poplar::Tensor mul (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Multiply each element in A by the corresponding element in B. More...
 
void mulInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of mul().
 
void mulWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of mul() to the given output tensor.
 
poplar::Tensor neq (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Check if each element in A is not equal to the corresponding element in B. More...
 
void neqInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of neq().
 
void neqWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of neq() to the given output tensor.
 
poplar::Tensor pow (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute each element in A to the power of the corresponding element in B. More...
 
void powInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of pow().
 
void powWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of pow() to the given output tensor.
 
poplar::Tensor rem (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Compute the remainder of each element in A divided by the corresponding element in B. More...
 
void remInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of rem().
 
void remWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of rem() to the given output tensor.
 
poplar::Tensor shiftLeft (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Shift the elements of A left by the corresponding elements of B. More...
 
void shiftLeftInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of shiftLeft().
 
void shiftLeftWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of shiftLeft() to the given output tensor.
 
poplar::Tensor shiftRight (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Shift the elements of A right by the corresponding elements of B. More...
 
void shiftRightInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of shiftRight().
 
void shiftRightWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of shiftRight() to the given output tensor.
 
poplar::Tensor shiftRightSignExtend (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Shift the elements of A right with sign extension by the corresponding elements of B. More...
 
void shiftRightSignExtendInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of shiftRightSignExtend().
 
void shiftRightSignExtendWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of shiftRightSignExtend() to the given output tensor.
 
poplar::Tensor sub (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Subtract the elements of B from A and return the result in a new tensor. More...
 
void subInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of sub().
 
void subWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of sub() to the given output tensor.
 
poplar::Tensor varianceToInvStdDev (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Convert variance to inverse standard deviation. More...
 
void varianceToInvStdDevInPlace (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Update the input tensor with the result of varianceToInvStdDev().
 
void varianceToInvStdDevWithOutput (poplar::Graph &graph, const poplar::Tensor &A, const poplar::Tensor &B, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Write the result of varianceToInvStdDev() to the given output tensor.
 
poplar::Tensor pad (poplar::Graph &graph, const poplar::Tensor &t, const std::vector< std::ptrdiff_t > &paddingLower, const std::vector< std::ptrdiff_t > &paddingUpper, float val=0.0f, padding::MappingMethod mappingMethod=padding::MappingMethod::ZERO)
 Return a tensor with constant padding added. More...
 
poplar::Tensor pad (poplar::Graph &graph, const poplar::Tensor &t, std::ptrdiff_t paddingLower, std::ptrdiff_t paddingUpper, unsigned dim, float val=0.0f, padding::MappingMethod mappingMethod=padding::MappingMethod::ZERO)
 Return a tensor with constant padding added to one dimension. More...
 
poplar::Tensor reduce (poplar::Graph &graph, const poplar::Tensor &in, const poplar::Type &outType, const std::vector< std::size_t > &dims, ReduceParams params, std::vector< poplar::ComputeSet > &css, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Apply a reduction operation to a tensor. More...
 

Detailed Description

Common functions, such as elementwise and reductions.

Enumeration Type Documentation

◆ Operation

enum class popops::Operation
strong

Type of operation to use in a reduction.

See reduce() for example use.

Enumerator
LOGICAL_AND 

Only supports boolean operands.

LOGICAL_OR 

Only supports boolean operands.

SQUARE_ADD 

Squares each element before applying ADD reduction.

LOG_ADD 

Reduce using acc = a+log(1+exp(b-a))

◆ SortOrder

enum class popops::SortOrder
strong

Defines a required order for sorting operations.

Enumerator
NONE 

No ordering is required.

ASCENDING 

Sort in ascending order.

DESCENDING 

Sort in descending order.

Function Documentation

◆ abs()

poplar::Tensor popops::abs ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the absolute value of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::abs(a), where a is an element of A.

◆ add()

poplar::Tensor popops::add ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Add each element in A to the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a + b, where a and b are the corresponding elements of A and B tensors respectively.

◆ allTrue()

poplar::Tensor popops::allTrue ( poplar::Graph graph,
poplar::Tensor  A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Given a boolean tensor, compute the logical AND of all its elements.

A new variable is created to store the result.

Parameters
graphThe Poplar graph.
AThe boolean tensor.
progThe program sequence to add this operation to.
debugContextOptional debug information.
Returns
A variable that holds the result of the operation.
Exceptions
poputil::poplibs_errorIf the elements of A are not booleans.

◆ asin()

poplar::Tensor popops::asin ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the arc-sine of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::asin(a), where a is an element of A.

◆ atan2()

poplar::Tensor popops::atan2 ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the two argument arctangent of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of atan2(a, b), where a and b are the corresponding elements of A and B tensors respectively.

◆ bitwiseAnd()

poplar::Tensor popops::bitwiseAnd ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the bitwise AND of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a & b, where a and bare the corresponding elements of A and B tensors respectively.

◆ bitwiseNot()

poplar::Tensor popops::bitwiseNot ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the bitwise NOT operation for each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of ~a, where a is an element of A.

◆ bitwiseOr()

poplar::Tensor popops::bitwiseOr ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the bitwise OR of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a | b, where a and b are the corresponding elements of A and B tensors respectively.

◆ bitwiseXnor()

poplar::Tensor popops::bitwiseXnor ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the bitwise XNOR of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of !(a ^ b), where a and b are the corresponding elements of A and B tensors respectively.

◆ bitwiseXor()

poplar::Tensor popops::bitwiseXor ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the bitwise XOR of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a ^ b, where a and b are the corresponding elements of A and B tensors respectively.

◆ cast() [1/6]

poplar::Tensor popops::cast ( poplar::Graph graph,
const poplar::Tensor src,
const poplar::Type dstType,
const poplar::Tensor metadata,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Cast elements of the specified src tensor to dstType, returning the result as a new tensor.

Note: If dstType == src.elementType(), then the operation is a copy.

Parameters
graphThe graph that the operation will be added to.
srcSource tensor to cast.
dstTypeThe type of the destination tensor.
metadataA tensor of type QUARTER_METADATA initialised with the format and scale to use when casting to the destination tensor. The returned tensor will contain this metadata.
progProgram to add the cast operation to.
debugContextOptional debug information.
Returns
The resultant cast tensor.

◆ cast() [2/6]

poplar::Tensor popops::cast ( poplar::Graph graph,
const poplar::Tensor src,
const poplar::Type dstType,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Cast elements of the specified src tensor to dstType, returning the result as a new tensor.

Note: If dstType == src.elementType(), then the operation is a copy.

Parameters
graphThe graph that the operation will be added to.
srcSource tensor to cast.
dstTypeThe type of the destination tensor.
progProgram to add the cast operation to.
debugContextOptional debug information.
Returns
The resultant cast tensor.

◆ cast() [3/6]

poplar::Tensor popops::cast ( poplar::Graph graph,
poplar::Tensor  src,
const poplar::Type dstType,
const poplar::Tensor metadata,
poplar::ComputeSet  cs,
const poplar::DebugContext debugContext = {} 
)

Create vertices to cast elements of the specified src tensor to dstType, returning the result as a new tensor.

The vertices are added to the specified compute set.

Parameters
graphThe graph that the operation will be added to.
srcSource tensor.
dstTypeDestination type.
metadataA tensor of type QUARTER_METADATA initialised with the format and scale to use when casting to the destination tensor. The returned tensor will contain this metadata.
csCompute set to add the vertices to.
debugContextOptional debug information.
Returns
Resultant destination tensor.

◆ cast() [4/6]

poplar::Tensor popops::cast ( poplar::Graph graph,
poplar::Tensor  src,
const poplar::Type dstType,
poplar::ComputeSet  cs,
const poplar::DebugContext debugContext = {} 
)

Create vertices to cast elements of the specified src tensor to dstType, returning the result as a new tensor.

The vertices are added to the specified compute set.

Parameters
graphThe graph that the operation will be added to.
srcSource tensor.
dstTypeDestination type.
csCompute set to add the vertices to.
debugContextOptional debug information.
Returns
Resultant destination tensor.

◆ cast() [5/6]

poplar::program::Program popops::cast ( poplar::Graph graph,
poplar::Tensor  src,
poplar::Tensor  dst,
const poplar::DebugContext debugContext = {} 
)

Create a program to copy tensor casting between types (for example, half->float).

Precondition: src.shape() == dst.shape()

Note: If dst.elementType() == src.elementType(), then the operation is just a copy.

Parameters
graphThe graph that the operation will be added to.
srcSource tensor.
dstDestination tensor.
debugContextOptional debug information.
Returns
The program to perform this operation.

◆ cast() [6/6]

void popops::cast ( poplar::Graph graph,
poplar::Tensor  src,
poplar::Tensor  dst,
poplar::ComputeSet  cs 
)

Create vertices to copy element wise from the src tensor to the dst tensor casting between types (for example, half->float).

The vertices are added to the specified compute set.

Precondition: src.shape() == dst.shape()

Parameters
graphThe graph that the operation will be added to.
srcSource tensor.
dstDestination tensor.
csCompute set to add the vertices to.

◆ cbrt()

poplar::Tensor popops::cbrt ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the cube-root for each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::cbrt(a), where a is an element of A.

◆ ceil()

poplar::Tensor popops::ceil ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the ceiling of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::ceil(a), where a is an element of A.

◆ checkAccuracyWhenCast()

poplar::Tensor popops::checkAccuracyWhenCast ( poplar::Graph graph,
const poplar::Tensor input,
poplar::Type  outputType,
double  tolerance,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Helper function which checks the relative error in the tensor input when casting it to type outputType.

The result is a single element bool tensor which is set to true if the error is less than tolerance.

Preconditions:

  • input.elementType() == FLOAT
  • outputType == HALF
  • input.numElements() == 1
Parameters
graphThe graph that the operation will be added to.
inputInput tensor.
outputTypeOutput type after the cast operation.
toleranceAllowed tolerance in error from cast operation.
progProgram to add the check onto.
debugContextOptional debug information.
Returns
Boolean tensor indicating that the error is less than tolerance.
Exceptions
poputil::poplibs_errorIf either input or outputType are not either half or float.

◆ checkTypes()

template<typename constType >
void popops::checkTypes ( poplar::Type  elementType,
constType   
)
inline

Check that the host compile-time type constType is compatible with the run-time IPU type elementType.

Parameters
elementTypeThe run-time IPU type.
constantUnused.
Template Parameters
constTypeThe host compile-time type.
Exceptions
std::runtime_errorIf the types are not compatible.

◆ clamp()

poplar::Tensor popops::clamp ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
const poplar::Tensor C,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Populate the returned tensor with elements from A but clamp them such that each element is greater than or equal to the corresponding element in B and less than or equal to the corresponding element in C.

That is, for each element in the returned tensor compute: min(max(a, b), c), where a, and c are the corresponding elements in the tensors A, B and C respectively.

Parameters
graphThe graph to update.
AThe tensor containing the elements to clamp.
BThe tensor containing the elements to use as minimums.
CThe tensor containing the elements to use as maximums.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor containing the elements resulting from the application of the expression across the tensors.

◆ cos()

poplar::Tensor popops::cos ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the cosine of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::cos(a), where a is an element of A.

◆ countedForLoop() [1/2]

poplar::program::Sequence popops::countedForLoop ( poplar::Graph graph,
const poplar::Tensor count,
int  initialCount,
const poplar::Tensor countLimit,
int  countStep,
const poplar::program::Program body,
const poplar::DebugContext debugContext = {} 
)

Create a for-loop program with constant initial count and increment, and a tensor as the end value.

The use of a tensor as the loop end value means that the number of iterations can be calculated at run time. The loop count variable count is provided by the program that calls the loop program so it can be passed to the body program.

The program is equivalent to:

for(unsigned count = initialCount; count != countLimit; count += countStep){
body;
}
Parameters
graphThe graph the loop program will be added to.
countThe loop count tensor, available to the body program with element type INT or UNSIGNED_INT. Value initialised by this function.
initialCountInitial counter value.
countLimitCount limit tensor.
countStepThe increment added to the count tensor on each loop pass.
bodyThe loop body program to run on each loop pass.
debugContextOptional debug information.
Returns
A program providing the above loop function.

◆ countedForLoop() [2/2]

poplar::program::Sequence popops::countedForLoop ( poplar::Graph graph,
int  initialCount,
const poplar::Tensor countLimit,
int  countStep,
const poplar::program::Program body,
const poplar::DebugContext debugContext = {} 
)

Create a for loop program with constant initial count and increment and a tensor as the end value.

The use of a tensor as the loop end value means that the number of iterations can be calculated at run time. The count tensor is created internally and is not available to the body program.

The program is equivalent to:

for(unsigned count = initialCount; count != countLimit; count += countStep){
body;
}
Parameters
graphThe graph the loop program will be added to.
initialCountInitial counter value.
countLimitCount limit tensor.
countStepThe increment added to the count tensor on each loop pass.
bodyThe loop body program to run on each loop pass.
debugContextOptional debug information.
Returns
A program providing the above loop function

◆ countedLoop() [1/2]

poplar::program::Sequence popops::countedLoop ( poplar::Graph graph,
std::size_t  begin,
std::size_t  end,
size_t  step,
const CountedLoopBodyType &  body,
const poplar::DebugContext debugContext = {} 
)

Create a loop program with constant initial count, increment and end value.

The loop count is passed to the body program.

The program is equivalent to:

for(unsigned i = begin; i != end; i += step){
body;
}
Parameters
graphThe graph the loop program will be added to.
beginInitial counter value.
endCounter end value (exclusive).
stepThe increment added on each loop pass (must be greater than zero).
bodyThe loop body program to run on each loop pass.
debugContextOptional debug information.
Returns
A program providing the above loop function.

◆ countedLoop() [2/2]

poplar::program::Sequence popops::countedLoop ( poplar::Graph graph,
std::size_t  count,
const CountedLoopBodyType &  body,
const poplar::DebugContext debugContext = {} 
)

Create a loop program which executes count times.

The loop count is passed to the body program.

The program is equivalent to:

for(unsigned i = 0; i != count; i += 1){
body;
}

This is equivalent to poplar::Program::Repeat but with a loop counter that is passed to the body program. (It is actually implemented using poplar::Program::RepeatWhileTrue with a test for the count variable reaching count.)

Parameters
graphThe graph the loop program will be added to.
countNumber of loop iterations to execute.
bodyThe loop body program to run on each loop pass.
debugContextOptional debug information.
Returns
A program providing the above loop function.

◆ countLeadingZeros()

poplar::Tensor popops::countLeadingZeros ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the number of binary leading zeros of each element in A.

Note
If the element is zero then it is treated as 32 leading zeros.
Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of a ? __builtin_clz(a) : 32, where a is an element of A.

◆ createGatherInput() [1/2]

poplar::Tensor popops::createGatherInput ( poplar::Graph graph,
const poplar::Type type,
const std::vector< std::size_t > &  inputShape,
const std::vector< std::size_t > &  sliceSizes,
std::vector< unsigned >  startIndexMap,
const poplar::DebugContext debugContext = {} 
)

Create the input of the gather given a start index map.

This is designed to spread the gather, and each dynamic slice within the gather, across the tiles evenly.

Parameters
graphThe Poplar graph.
typeThe data type of the required tensor.
inputShapeThe desired shape of the input.
sliceSizessliceSizes[i] is the bounds for the slice on dimension i.
startIndexMapA map that describes how to map indices in indices in gather() to legal indices into the input.
debugContextOptional debug information.
Returns
A tensor with the desired shape.

◆ createGatherInput() [2/2]

poplar::Tensor popops::createGatherInput ( poplar::Graph graph,
const poplar::Type type,
const std::vector< std::size_t > &  operandShape,
unsigned  axis,
GatherParams  params = {},
const poplar::DebugContext debugContext = {} 
)

Create the input of the gather with only a single gather axis.

This is designed to spread the gather, and each dynamic slice within the gather, across the tiles evenly.

Parameters
graphThe Poplar graph.
typeThe data type of the required tensor.
operandShapeThe desired shape of the input.
axisThe axis that will be gathered on.
paramsThe same parameters as used by the gather().
debugContextOptional debug information.
Returns
A tensor with the desired shape.

◆ createGroupedIndicesTensor()

poplar::Tensor popops::createGroupedIndicesTensor ( poplar::Graph graph,
const std::size_t  groupSize,
const std::vector< std::size_t > &  dims,
const std::size_t  numIndices,
const SlicePlan plan,
const poplar::OptionFlags ,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor with a group dimension to contain indices for slicing or updating a tensor efficiently.

Groups allow multiple independent slice/update operations of the same size to be done in parallel. Indices have the same bounds for every element in the group.

dims is defined as in the non-grouped version. They do not include a group dimension.

It is an error to call this function without a valid plan and groupSize must match the group size with which the operation is planned in plan.

Parameters
graphThe Poplar graph.
groupSizeThe size of the group
dimsThe dimensions of a tensor to be sliced/updated that will be sliced/updated using these indices.
numIndicesThe number of indices this tensor should contain
planPlan describing how the slicing/updating operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.
Returns
A tensor of shape [groupSize, numIndices, dims.size()] mapped appropriately to be used as the indices for a slice/update operation. Element type is always UNSIGNED_INT.

◆ createGroupedSliceableTensor()

poplar::Tensor popops::createGroupedSliceableTensor ( poplar::Graph graph,
const poplar::Type type,
const std::size_t  groupSize,
const std::vector< std::size_t > &  shape,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor with a group dimension to be sliced/updated efficiently.

Groups allow multiple independent slice/update operations of the same size to be done in parallel.

The shape, dims, and sizes parameters are defined as in createSliceableTensor() and are used for every group.

A valid plan must be provided. The returned tensor will be laid out according to the plan.

Parameters
graphThe Poplar graph.
typeThe type of the elements.
groupSizeThe group size.
shapeThe shape of the tensor to be slice/updated.
dimsThe dimensions of the tensor that will be slice/updated.
sizesThe size of the slice in each of the dimensions.
planPlan describing how the slicing/updating operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.
Returns
A tensor suitably mapped with groupSize as the first dimension and the remaining dimensions as in shape.

◆ createGroupedSliceTensor()

poplar::Tensor popops::createGroupedSliceTensor ( poplar::Graph graph,
const poplar::Type type,
const std::size_t  groupSize,
const std::vector< std::size_t > &  shape,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
const std::size_t  numIndices,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor with a group dimension that is used as a result of slicing, or as an input to an update.

The group dimension is the first dimension of the output tensor.

Groups allow multiple independent slice/update operations of the same size to be done in parallel.

The shape, dims, and sizes parameters are defined as in createGroupedSliceTensor and are used for every group.

The returned tensor is laid out according to the plan for the slice/update operation. It is an error to call this function without a valid plan.

Parameters
graphThe Poplar graph.
typeThe type of the elements.
groupSizeThe group size
shapeThe shape of the tensor to be slice/updated.
dimsThe dimensions of the tensor that will be sliced/updated.
sizesThe number of elements of each dimension in dims that will be sliced/updated.
numIndicesThe number of slices this tensor should contain.
planPlan describing how the slicing/updating operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.
Returns
A tensor with shape [groupSize, numIndices, shape...]

◆ createHostSliceableTensor()

IndicesAndTensor popops::createHostSliceableTensor ( poplar::Graph graph,
const poplar::Type type,
const std::vector< size_t > &  shape,
const bool  isRead,
const poplar::DebugContext debugContext = {} 
)

Create a Tensor that is well laid out for a host exchange copy and at the same time create the index tensor for the copy.

The shape must be size 2, dim(1) must be the size of the datastream or remote buffer, if using a copy from a remote buffer with multiple slice indices dim(0) must be num slice indices, other wise dim(0) is 1.

Parameters
graphThe Poplar graph to add the tensor to.
typeThe element type of the tensor created.
shapeThe hape of created tensor.
isReadIf true, the tensor will be read by the host. If false, the tensor data will be written to the host. If isRead is true, tile imbalance is likely to be greater.
Returns
Two tensors: the indices, which will have size shape[0] and the tensor that will be written to.

◆ createHostTransferableTensor()

poplar::Tensor popops::createHostTransferableTensor ( poplar::Graph graph,
const poplar::Type type,
const std::vector< size_t > &  shape,
bool  isRead,
const poplar::DebugContext debugContext = {} 
)

Create a tensor that is well laid out for a host exchange copy.

Parameters
graphThe graph to add the tensor to.
typeThe element type of the tensor created.
shapeThe shape of the tensor created.
isReadIf true, the tensor will be read by the host. If false, the tensor data will be written to the host. Setting isRead to true is likely to make the read operation faster without affecting the write, but is also likely to cause greater tile imbalance.
Returns
The tensor created.

◆ createIndicesTensor()

poplar::Tensor popops::createIndicesTensor ( poplar::Graph graph,
const std::vector< std::size_t > &  dims,
std::size_t  numIndices,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor to contain indices for slicing or updating a tensor efficiently.

Parameters
graphThe Poplar graph.
dimsThe dimensions of a tensor to be sliced/updated that will be sliced/updated using these indices.
numIndicesThe number of indices this tensor should contain
planPlan describing how the slicing/updating operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.
Returns
A tensor of shape [numIndices, dims.size()] mapped appropriately to be used as the indices for a slice/update operation. Element type is always UNSIGNED_INT.

◆ createNormaliseImageInput()

poplar::Tensor popops::createNormaliseImageInput ( poplar::Graph graph,
const poplar::Type type,
const poplar::ArrayRef< std::size_t >  shape,
const poplar::DebugContext debugContext = {} 
)

Add a tensor for a 3-channel image suitable for padding to 4 channels.

Parameters
graphThe graph to which the tensor will be added.
typeThe type of the elements. Must be UNSIGNED_CHAR, HALF or FLOAT.
shapeRequired tensor shape. Must have an inner dimension of three.
debugContextDebugging context.

◆ createOutputForElementWiseOp()

poplar::Tensor popops::createOutputForElementWiseOp ( poplar::Graph graph,
const std::vector< poplar::Tensor > &  inputs,
const poplar::Type outputType,
const poplar::DebugContext debugContext = {} 
)

Create a tensor for use as the output of an element-wise operation (operation with no dependency between more than one element of the output and any given element of any input tensor).

Use the mapping of this tensor to map element-wise operations to tiles to produce an operation that is computationally balanced across tiles and which minimises exchange.

All input tensors must have the same shape.

Parameters
graphA graph to add the tensor to and which the inputs belong to.
inputsList of input tensors for the element-wise operation.
outputTypeThe element type of the tensor.
debugContextOptional debug information.
Returns
A tensor with the same shape as the given inputs, with a complete tile mapping.

◆ createSliceableTensor() [1/2]

poplar::Tensor popops::createSliceableTensor ( poplar::Graph graph,
const poplar::Type type,
const std::vector< size_t > &  shape,
const std::vector< size_t > &  dims,
const std::vector< size_t > &  sizes,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor to be sliced/updated efficiently.

The returned tensor will be laid out according to the plan.

Parameters
graphThe Poplar graph.
typeThe type of the elements.
shapeThe shape of the tensor to be slice/updated.
dimsThe dimensions of the tensor that will be slice/updated.
sizesThe size of the slice in each of the dimensions.
planPlan describing how the slicing/updating operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.
Returns
A tensor shape shape that is suitably mapped.

◆ createSliceableTensor() [2/2]

poplar::Tensor popops::createSliceableTensor ( poplar::Graph graph,
const poplar::Type type,
const std::vector< size_t > &  shape,
const std::vector< size_t > &  dims,
const std::vector< size_t > &  sizes,
std::size_t  minGrainSize = 0,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor to be sliced/updated efficiently.

The returned tensor will be spread over as many tiles as possible while respecting the minimum number of elements per tile (minGrainSize) and still being in a form that can be sliced/updated efficiently.

Parameters
graphThe Poplar graph.
typeThe type of the elements.
shapeThe shape of the tensor to be slice/updated.
dimsThe dimensions of the tensor that will be slice/updated.
sizesThe size of the slice in each of the dimensions.
minGrainSizeThe minimum elements per slice mapped to each tile
debugContextOptional debug information.
Returns
A tensor shape shape that is suitably mapped

◆ createSliceableTensorFromSlice()

poplar::Tensor popops::createSliceableTensorFromSlice ( poplar::Graph graph,
const poplar::Tensor s,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  numSlices,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor to be sliced/updated.

The tensor is mapped in a way that can be efficiently sliced and updated to/from the given slice tensor. It will be distributed across as many tiles as the given slice and with the same contiguous regions on each tile. The tensor's shape and mapping are derived from the reference slice tensor.

Parameters
graphThe Poplar graph.
sThe reference slice.
dimsThe dimensions of the returned tensor that will be sliced.
numSlicesThe number of independent slices in each sliced dimension.
debugContextOptional debug information.
Returns
A tensor to be sliced/updated.

◆ createSliceTensor() [1/2]

poplar::Tensor popops::createSliceTensor ( poplar::Graph graph,
const poplar::Tensor t,
const std::vector< size_t > &  dims,
const std::vector< size_t > &  sizes,
std::size_t  numIndices,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor that is used as a result of slicing, or as an input to an update.

Introspection on the tensor t is used to lay out the created tensor such that it can be used to efficiently update t.

Parameters
graphThe Poplar graph.
tThe tensor to be updated.
dimsThe dimensions of the tensor that will be sliced/updated.
sizesThe number of elements of each dimension in dims that will be sliced/updated.
numIndicesThe number of slices this tensor should contain.
planPlan describing how the slicing/updating operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.
Returns
A tensor with shape [numIndices, shape...] mapped appropriately to be sliced into/updated from.

◆ createSliceTensor() [2/2]

poplar::Tensor popops::createSliceTensor ( poplar::Graph graph,
const poplar::Type type,
const std::vector< std::size_t > &  shape,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
std::size_t  numIndices,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Create and map a tensor that is used as a result of slicing, or as an input to an update.

The returned tensor is laid out according to the plan for the slice/update operation.

Parameters
graphThe Poplar graph.
typeThe type of the elements.
shapeThe shape of the tensor to be slice/updated.
dimsThe dimensions of the tensor that will be sliced/updated.
sizesThe number of elements of each dimension in dims that will be sliced/updated.
numIndicesThe number of slices this tensor should contain.
planPlan describing how the slicing/updating operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.
Returns
A tensor with shape [numIndices, shape...]

◆ createTopKInput()

poplar::Tensor popops::createTopKInput ( poplar::Graph graph,
const poplar::Type type,
const std::vector< std::size_t > &  shape,
const TopKParams params,
const poplar::DebugContext debugContext = {} 
)

Create an return a new tensor laid out optimally to be used as an input to a topK operation with the given parameters.

Parameters
graphThe Poplar graph to add the tensor to.
typeThe Poplar type of elements in the returned tensor.
shapeThe shape of the returned tensor.
paramsThe parameters of the top k that the returned tensor will be used as input to.
debugContextOptional debug information.
Returns
A newly created tensor with shape shape and full tile mapping.

◆ div()

poplar::Tensor popops::div ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Divide each element in A by the corresponding element in B.

Parameters
graphThe graph to update.
AThe tensor of dividends.
BThe tensor of divisors.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a / b, where a and b are the corresponding elements of A and B tensors respectively.

◆ dynamicSlice()

poplar::Tensor popops::dynamicSlice ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor offset,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Slice a tensor based on offsets specified by a tensor.

dims gives the dimensions to slice, sizes defines the size of the slice in those dimensions and offset gives the base offsets on each execution.

offset[0], dims and sizes must have the same size. offset may have a second dimension with an element per tile, which can eliminate exchange.

Note
If the elements of a single slice cannot be well spread across available tiles (for example, because it has fewer elements than the available number of tiles) then the operation as a whole will also have poor tile balance and consequently poor tile memory balance.
Parameters
graphThe Poplar graph.
tThe source tensor.
offsetA tensor of offsets at which the output is extracted.
dimsThe dimensions of t to slice.
sizesThe size of the slice in each of the dimensions in dims.
progThe program to be extended
debugContextOptional debug information.
Returns
The specified subtensor

◆ dynamicSliceWithOutput()

void popops::dynamicSliceWithOutput ( poplar::Graph graph,
const poplar::Tensor output,
const poplar::Tensor t,
const poplar::Tensor offset,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Slice a tensor based on offsets specified by a tensor.

dims gives the dimensions to slice, sizes defines the size of the slice in those dimensions and offset gives the base offsets on each execution.

offset[0], dims and sizes must have the same size. offset may have a second dimension with an element per tile, which can eliminate exchange.

Parameters
graphThe Poplar graph.
outputThe output tensor, This should ideally be created with createSliceTensor to maximise efficiency,
tThe source tensor.
offsetA tensor of offsets at which the output is extracted.
dimsThe dimensions of t to slice.
sizesThe size of the slice in each of the dimensions in dims.
progThe program to be extended
debugContextOptional debug information.

◆ dynamicUpdate()

void popops::dynamicUpdate ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor s,
const poplar::Tensor offset,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Update a subtensor at offsets read from a tensor.

dims gives the dimensions that are partially updated, by sizes elements, at offsets offset. Unspecified dimensions are copied in full with zero offset.

offset[0], dims and sizes must have the same size. offset may have a second dimension with an element per tile, which can eliminate exchange.

Parameters
graphThe Poplar graph.
tThe tensor to update.
sThe updates.
offsetThe offset within t to be updated.
dimsThe dimensions to be dynamically updated.
sizesThe size of the update in each of the dimensions in dims.
progThe program to be extended.
debugContextOptional debug information.

◆ encodeOneHot() [1/2]

void popops::encodeOneHot ( poplar::Graph graph,
const poplar::Tensor indices,
const poplar::Tensor encoded,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Encode a given set of indices as a set of one-hot vectors per-index with a hot element at that index.

That is, given a one-dimensional indices tensor with length N and a two-dimensional encoded tensor with shape N * x, encoded is a tensor with a single element equal to 1, and all others equal 0. The single hot element in each row is given by the indices in indices.

Parameters
graphThe graph to add the tensor and any vertices needed for the encoding to.
encodedTensor to encode output to.
indices1-dimensional tensor containing indices to encode as one-hot vectors. A codepoint MASKED_LABEL_CODE is reserved to indicate that the encoding is not done for that index.
progSequence which the programs that perform the encoding are added to.
debugContextOptional debug information.
Exceptions
poputil::poplibs_errorIf encoded is not two dimensional.
poputil::poplibs_errorIf indices and encoded do not have the same number of rows.
poputil::poplibs_errorIf elements of indices are not an integer type.

◆ encodeOneHot() [2/2]

void popops::encodeOneHot ( poplar::Graph graph,
const poplar::Tensor indices,
const poplar::Tensor encoded,
poplar::program::Sequence prog,
const poplar::Tensor on,
const poplar::Tensor off,
const poplar::DebugContext debugContext = {} 
)

Encode a given set of indices as a set of one-hot vectors per-index with a hot element at that index.

That is, given a one-dimensional indices tensor with length N and a two-dimensional encoded tensor with shape N * x encoded is a tensor with a single element equal to on, and all others equal to off as given by the user. The single hot element in each row is given by the indices in indices.

Parameters
graphThe graph to add the tensor and any vertices needed for the encoding to.
encodedTensor to encode output to.
indices1-dimensional tensor containing indices to encode as one-hot vectors.
progSequence which the programs that perform the encoding are added to.
debugContextOptional debug information.
onValue which represents the "On" state in the one hot encoded output.
offValue which represents the "Off" state.
Exceptions
poputil::poplibs_errorIf encoded is not two dimensional.
poputil::poplibs_errorIf indices and encoded do not have the same number of rows.
poputil::poplibs_errorIf elements of indices are not an integer type.

◆ eq()

poplar::Tensor popops::eq ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Check if each element in A is equal to the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a == b, where a and b are the corresponding elements of A and B tensors respectively.

◆ erf()

poplar::Tensor popops::erf ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the error function of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::erf(a), where a is an element of A.

◆ exp()

poplar::Tensor popops::exp ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the exponential of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::exp(a), where a is an element of A.

◆ expm1()

poplar::Tensor popops::expm1 ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the exponential of each element in A minus one.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::expm1(a), where a is an element of A.

◆ fill() [1/4]

template<typename FillValueType >
void popops::fill ( poplar::Graph graph,
const poplar::Tensor t,
const std::vector< std::vector< poplar::Interval > > &  mapping,
poplar::ComputeSet  fillCS,
FillValueType  fillValue 
)

Appends vertices to fillCS which fills elements in mapping of t which reside on tiles represented with mapping.

Parameters
graphThe graph that the operation will be added to.
tThe tensor whose elements are to be set to zero.
mappingThe tensor's region mapping per tile. Each element describes a region mapping of a tile (ordered). That is, mapping[0] is the region of t mapped onto tile 0.
fillCSCompute set to add the operation into.
fillValueThe value to fill t with.

◆ fill() [2/4]

template<typename FillValueType >
void popops::fill ( poplar::Graph graph,
const poplar::Tensor t,
poplar::program::Sequence prog,
FillValueType  fillValue,
const poplar::DebugContext debugContext = {} 
)

Appends programs to prog which fills all elements of the tensor t with a value of fillValue.

Note
The type of fillValue must be compatible with the element type of t.
Parameters
graphThe graph that the operation will be added to.
tThe tensor whose elements are to be filled.
progPoplar program sequence to append the operation onto.
fillValueThe value to fill t with.
debugContextOptional debug information.

◆ fill() [3/4]

template<typename FillValueType >
void popops::fill ( poplar::Graph graph,
const poplar::Tensor t,
unsigned  tile,
poplar::ComputeSet  fillCS,
FillValueType  fillValue 
)

Appends vertices to fillCS which fills all elements of t which reside on tile tile.

Parameters
graphThe graph that the operation will be added to.
tThe tensor whose elements are to be set to zero.
tileTile on which the tensor is mapped to.
fillCSCompute set to add the operation into.
fillValueThe value to fill t with.

◆ fill() [4/4]

template<typename FillValueType >
void popops::fill ( poplar::Graph graph,
poplar::Tensor  t,
const std::vector< poplar::Interval > &  tileRegions,
unsigned  tile,
poplar::ComputeSet  fillCS,
FillValueType  fillValue 
)

Appends vertices to fillCS which fills elements in tileRegions of t which reside on tile tile.

Parameters
graphThe graph that the operation will be added to.
tThe tensor whose elements are to be set to zero.
tileRegionsRegion mapping of the tensor on tile.
tileTile which the regions relate to.
fillCSCompute set to add the operation into.
fillValueThe value to fill t with.

◆ floor()

poplar::Tensor popops::floor ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the floor of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::floor(a), where a is an element of A.

◆ gather() [1/2]

poplar::Tensor popops::gather ( poplar::Graph graph,
const poplar::Tensor input,
const poplar::Tensor indices,
std::size_t  indexVectorDim,
const std::vector< std::size_t > &  offsetDims,
const std::vector< std::size_t > &  sliceSizes,
const std::vector< std::size_t > &  collapsedSliceDims,
const std::vector< unsigned > &  startIndexMap,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

The gather operation stitches together several slices (each slice at a potentially different runtime offset) of an input tensor.

To achieve the best performance, the input tensor should be created with createGatherInput().

Parameters
graphThe Poplar graph.
inputThe tensor we are gathering from.
indicesTensor containing the starting indices of the slices we gather.
indexVectorDimThe dimension in indices that "contains" the starting indices.
offsetDimsThe set of dimensions in the output shape that offset into a tensor sliced from input.
sliceSizessliceSizes[i] is the bounds for the slice on dimension i.
collapsedSliceDimsThe set of dimensions in each slice that are collapsed away. These dimensions must have size 1.
startIndexMapA map that describes how to map indices in indices to legal indices into input.
progThe program sequence to add this operation to.
debugContextOptional debug information.
Note
When indexVectorDim == indices.rank(), the indices are interpreted as scalar values.
This is a near direct port of https://www.tensorflow.org/xla/operation_semantics#gather from tensorflow/compiler/xla/service/gather_expander.cc
Returns
The gathered slices from the input.

Example use where we want to take 2 elements from a given tensor:

// The runtime defined input tensor
input = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; // shape = {3, 3}

// The runtime defined indices tensor containing the coords we want to
// extract
indices = {{1, 1}, {2, 1}}; // shape = {2, 2}

// We want to extract elems at [1, 1] and [2, 1] from the input
// To achieve this we need to define the other parameters correctly

// We want to treat the rows of indices as coords into the input tensor
indexVectorDim = 1;

// None of the output dims will correspond to any of the input dims
offsetDims = {};

// We will be taking 1x1 slices to pick single elements
sliceSizes = {1, 1};

// We will collapse both dims of the input slices
collapsedSliceDims = {0, 1};

// An identity mapping between the indices coords and the input dims
startIndexMap = {0, 1};

// Perform the desired gather
result = gather(input,
                indices,
                indexVectorDim,
                offsetDims,
                sliceSizes
                collapsedSliceDims,
                startIndexMap) = {5, 8}; // shape = {2}

◆ gather() [2/2]

poplar::Tensor popops::gather ( poplar::Graph graph,
const poplar::Tensor input,
const poplar::Tensor indices,
unsigned  axis,
poplar::program::Sequence prog,
GatherParams  params,
const poplar::DebugContext debugContext = {} 
)

The gather operation stitches together several slices (each slice at a potentially different runtime offset) of an input tensor.

To achieve the best performance, the input tensor should be created with createGatherInput().

Parameters
graphThe Poplar graph.
inputThe tensor we are gathering from of rank x.
indicesTensor containing the indices of the slices we gather of rank y.
axisThe axis to gather on. The axis must be less than x.
progThe program sequence to add this operation to.
paramsParameters for the form of the gather.
debugContextOptional debug information.
Note
The indices are treated as offsets along the chosen axis. At this offset a slice of depth 1 in the axis dimension is taken.
Returns
The gathered slices from the input with rank y + (x - 1).

◆ geluErf()

poplar::Tensor popops::geluErf ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute (1 + erf(A/sqrt(2))) * A / 2 where all the operations are element-wise, and erf is the error function.

This is a very accurate implementation with low relative and absolute error.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of geluErf(a), where a is an element of A.

◆ getSliceMapping()

poplar::Graph::TileToTensorMapping popops::getSliceMapping ( poplar::Graph graph,
const poplar::Tensor t,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes 
)

Get the tile mapping for a slice of a tensor.

dims gives the dimensions to slice, sizes defines the size of the slice in those dimensions.

Parameters
graphThe Poplar graph.
tThe source tensor.
dimsThe dimensions of t to slice.
sizesThe size of the slice in each of the dimensions in dims.

◆ groupedMultiSlice()

poplar::Tensor popops::groupedMultiSlice ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor offsets,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Take multiple slices from a base tensor where the base tensor and the offsets tensor have the group dimension as the first dimension.

The indices given in the offsets tensor should be in the range [0, base.dim(1)]. Indices outside of this range are allowed but return undefined values.

The returned tensor will have a rank one greater than t. Its outer dimension is the group size and the second dimension will be offsets.dim(1). dims indexes the dimensions of each group in t. This makes it consistent with grouped variants of functions to create tensors. t can be created using createGroupedSliceableTensor() to ensure efficient mapping.

Parameters
graphThe Poplar graph.
tThe tensor being sliced.
offsetsThe offsets within t to be sliced.
dimsThe dimensions of t for each group.
sizesThe size of the update in each of the dimensions in dims.
progThe program to be extended.
planPlan describing how the operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.

◆ groupedMultiUpdate()

void popops::groupedMultiUpdate ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor s,
const poplar::Tensor offsets,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Update multiple slices in a tensor with a group dimension.

The tensors t s , and offsets have group dimension as the first dimension.

Parameters
graphThe Poplar graph.
tThe tensor being updated.
sThe slices to insert.
offsetsThe offsets within t to be updated.
dimsThe dimensions of each group of t to be updated.
sizesThe size of the update in each of the dimensions in dims.
progThe program to be extended.
planPlan describing how the operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.

◆ groupedMultiUpdateAdd()

void popops::groupedMultiUpdateAdd ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor s,
const poplar::Tensor offsets,
const poplar::Tensor scale,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Accumulate multiple slices in a tensor where the first dimension of the tensors t, s and offsets is the group dimension.

t, s must be of the same type

Parameters
graphThe Poplar graph.
tThe tensor being updated (must be rank 3).
sThe slices to accumulate.
offsetsThe offsets within t to be accumulated.
scaleThe scaling to apply to the update. The type of the tensor should be the same as that of t and s except for the case when t and s are of type HALF. In which case scale can be of type FLOAT or HALF.
dimsThe dimensions of of each group to be accumulated.
sizesThe size of the accumulate in each of the dimensions in dims.
progThe program to be extended.
planPlan describing how the operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.

◆ groupedMultiUpdateMax()

void popops::groupedMultiUpdateMax ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor s,
const poplar::Tensor offsets,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Find maximum over multiple slices in a tensor with a group dimension.

The tensors t, s, offsets have groups as their first dimension. The offsets tensor contains indices per group which update elements of the corresponding group.

Parameters
graphThe Poplar graph.
tThe tensor being updated (must be rank 2).
sThe slices to find maximum over.
offsetsThe offsets within t to find maximum over.
dimsThe dimensions of each group of t to find maximum over (must be rank 1).
sizesThe size of the update in each of the dimensions in dims.
progThe program to be extended.
planPlan describing how the operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.

◆ gt()

poplar::Tensor popops::gt ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Check if each element in A is greater than the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a > b, where a and b are the corresponding elements of A and B tensors respectively.

◆ gteq()

poplar::Tensor popops::gteq ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Check if each element in A is greater than or equal to the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a >= b, where a and b are the corresponding elements of A and B tensors respectively.

◆ hasNaN()

poplar::Tensor popops::hasNaN ( poplar::Graph graph,
const poplar::Tensor src,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Test for NaN values in a tensor.

Takes a tensor of any shape and type float or half and returns a new scalar bool tensor whose only element is true if any of the elements of the src tensor contained a NaN.

Parameters
graphThe graph to add the tensor and any vertices to.
srcThe input tensor, the type must be floating point.
progSequence to add programs to, which perform the check.
debugContextOptional debug information.

◆ hasNaNOrInf()

poplar::Tensor popops::hasNaNOrInf ( poplar::Graph graph,
const poplar::Tensor src,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Test for NaN or Inf values in a tensor.

Takes a tensor of any shape and type float or half and returns a new scalar bool tensor whose only element is true if any of the elements of the src tensor contained a NaN or an Inf.

Parameters
graphThe graph to add the tensor and any vertices to.
srcThe input tensor, the type must be floating point.
progSequence to add programs to, which perform the check.
debugContextOptional debug information.

◆ histogram() [1/2]

poplar::Tensor popops::histogram ( poplar::Graph graph,
const poplar::Tensor input,
const poplar::Tensor levels,
bool  absoluteOfInput,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Gather a histogram representing the statistics of the input tensor.

Compare each element of input to each value in the levels tensor. Where input >= levels[N-1] and input < levels[N], the histogram entry for that range will be incremented by 1. The lowest and highest histogram entries are bounded only by levels[0] and levels[N-1], respectively. The function returns a histogram tensor with a size one greater than the size of the levels tensor.

Histogram options

  • useFloatArithmeticWithUnsignedIntOutput (true, false) [=false]

    If true, use float arithmetic internally and reduce the result to unsigned int. This has the benefit of simplicity and speed, but integer accuracy limited by the 32-bit float data format (integers > 16,777,216 are not all exactly represented).

  • useFloatArithmetic (true, false) [=false]

    Deprecated:
    use useFloatArithmeticWithUnsignedIntOutput instead.

    If true, use float arithmetic internally and return a float result rather than an unsigned int result. This has the benefit of simplicity and speed, but integer accuracy limited by the 32-bit float data format (integers > 16,777,216 are not all exactly represented).

    The options useFloatArithmeticWithUnsignedIntOutput and useFloatArithmetic must not both be true.

Parameters
graphThe Poplar graph.
inputThe input tensor on which to gather histogram statistics.
levelsThe levels defining the comparisons to carry out in generating the histogram output.
absoluteOfInputIf true, the absolute value of each input is calculated before comparison to the levels data.
progA sequence program to which the code performing the histogram will be appended.
debugContextOptional debug information.
optionsA list of options to control the operation of the histogram function.
Returns
A tensor of type unsigned int that contains the levels + 1 histogram results. If the option useFloatArithmetic is "true" the returned tensor will have type float.
Exceptions
poplar::invalid_optionIf options useFloatArithmetic and useFloatArithmeticWithUnsignedIntOutput are both true.

◆ histogram() [2/2]

void popops::histogram ( poplar::Graph graph,
const poplar::Tensor input,
poplar::Tensor output,
bool  updateOutput,
const poplar::Tensor levels,
bool  absoluteOfInput,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Fill a tensor with a histogram representing the statistics of the input tensor.

Performs the same function as histogram() but writes the output to output. This must be one element larger than the levels tensor and have elements of type float or unsigned integer. This function allows histogram results to be accumulated over a number of calls using the updateOutput parameter.

Deprecated Behaviour The determination of the internally used arithmetic based on the type of the output tensor is deprecated.

The usage of output tensor argument of type FLOAT is deprecated.

Histogram options

  • useFloatArithmeticWithUnsignedIntOutput (true, false) [=false]

    If true, use float arithmetic internally and reduce the result to unsigned int. This has the benefit of simplicity and speed, but integer accuracy limited by the 32-bit float data format (integers > 16,777,216 are not all exactly represented).

The useFloatArithmetic option must be false.

Parameters
graphThe Poplar graph.
inputThe input tensor on which to gather histogram statistics.
outputThe output tensor which will store the histogram results.
updateOutputIf true, the histogram counts will be added to the values already in output.
levelsThe levels defining the comparisons to carry out in generating the histogram output.
absoluteOfInputIf true, the absolute value of each input is calculated before comparison to the levels data.
progA sequence program to which the code performing the histogram will be appended.
debugContextOptional debug information.
optionsA list of options to control the operation of the histogram function.
Exceptions
poputil::poplibs_errorIf option useFloatArithmeticWithUnsignedIntOutput is true and output does not have UNSIGNED_INT type.
poplar::invalid_optionIf option useFloatArithmetic is true.

◆ inv()

poplar::Tensor popops::inv ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the inverse of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of 1 / a, where a is an element of A.

◆ invStdDevToVariance() [1/2]

poplar::Tensor popops::invStdDevToVariance ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Convert the inverse standard deviation to variance.

Parameters
graphThe graph to update.
AThe source tensor.
BThe destination tensor.
progThe sequence to extend with the execution of conversion.
debugContextOptional debug information.
optionsA list of flags to pass to the expression evaluator.
Returns
A tensor where each element is the variance. Each element is the result of b = (1 / a) ^ 2, where a and b are the corresponding elements of A and B tensors respectively, and where A represents the inverse standard deviation and B the variance.

◆ invStdDevToVariance() [2/2]

poplar::Tensor popops::invStdDevToVariance ( poplar::Graph graph,
const poplar::Tensor src,
const poplar::Tensor epsilon,
poplar::program::Sequence prog,
const poplar::Type  dstType = poplar::FLOAT,
const poplar::DebugContext debugContext = {} 
)

Convert inverse standard deviation to variance.

Parameters
graphThe graph to update.
srcThe source tensor.
epsilonA tensor initialised with the epsilon parameter used in conversion. Must have a single element and have the same type as the input type. Alternatively, a float value can be used and the appropriate tensor will be created.
progThe sequence to extend with the execution of conversion.
dstTypeThe type of the tensor to be output. Must be FLOAT or equal to the input type.
debugContextOptional debug information
Returns
A tensor where each element is the variance. Each element is the result of b = (1 / a) ^ 2, where a and b are the corresponding elements of src and the result tensor respectively.

◆ iota() [1/2]

void popops::iota ( poplar::Graph graph,
const poplar::Tensor t,
int  startInteger,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Fill a tensor with a right-open range of signed integers: [startInteger, startInteger + length), where length is the number of elements in the mapped 1-D output tensor t.

The output tensor t must be of type INT.

Parameters
graphThe graph to add the tensor and any vertices needed for the operation.
t1-D tensor to write the encoded output to. The tensor must be mapped.
startIntegerThe start value in the output range.
progSequence which the programs that perform the encoding are added to.
debugContextOptional debug information.
Exceptions
poputil::poplibs_errorIf the rank of t is greater than 1.
poputil::poplibs_errorIf the type of t is not INT.

◆ iota() [2/2]

void popops::iota ( poplar::Graph graph,
const poplar::Tensor t,
unsigned  startInteger,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Fill a tensor with a right-open range of unsigned integers: [startInteger, startInteger + length), where length is the number of elements in the mapped 1-D output tensor t.

The output tensor t must be of type UNSIGNED_INT.

Parameters
graphThe graph to add the tensor and any vertices needed for the operation.
t1-D tensor to write the encoded output to. The tensor must be mapped.
startIntegerThe start value in the output range.
progSequence which the programs that perform the encoding are added to.
debugContextOptional debug information.
Exceptions
poputil::poplibs_errorIf the rank of t is greater than 1.
poputil::poplibs_errorIf the type of t is not UNSIGNED_INT.

◆ isFinite()

poplar::Tensor popops::isFinite ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Check if each element in A is finite.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::isfinite(a), where a is an element of A.

◆ log()

poplar::Tensor popops::log ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the log base-e of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::log(a), where a is an element of A.

◆ log1p()

poplar::Tensor popops::log1p ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the log base-e of each element in A plus one.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::log1p(a), where a is an element of A.

◆ logicalAnd()

poplar::Tensor popops::logicalAnd ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the logical AND (&&) of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a && b, where a and b are the corresponding elements of A and B tensors respectively.

◆ logicalNot()

poplar::Tensor popops::logicalNot ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the logical NOT of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of !a, where a is an element of A.

◆ logicalOr()

poplar::Tensor popops::logicalOr ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the logical OR (||) of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a || b, where a and b are the corresponding elements of A and B tensors respectively.

◆ lt()

poplar::Tensor popops::lt ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Check if each element in A is less than the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a < b, where a and b are the corresponding elements of A and B tensors respectively.

◆ lteq()

poplar::Tensor popops::lteq ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Check if each element in A is less than or equal to the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a <= b, where a and b are the corresponding elements of A and B tensors respectively.

◆ map()

poplar::Tensor popops::map ( poplar::Graph graph,
const expr::Expr expr,
const std::vector< poplar::Tensor > &  ts,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Map an expression across tensors.

Elementwise Options

  • enableGenerateCodelet (true, false) [=true]

    When true and the following conditions are met, poplar will generate a codelet to execute the map operation. Otherwise, it will sequence poplibs codelets to create the expression.

    • All of the inputs are of the same size
    • Inputs do not alias
    • Multiple operations are being performed
      Parameters
      graphThe graph to update.
      exprThe expression to map across the tensors. The placeholders in the expressions will be substituted with corresponding elements from the tensors in ts.
      tsThe list of tensors to map the expression across. If elements from these tensors are used in binary/ternary operations in the expression the numpy-style broadcast rules are used to match the shapes of the tensors (see poputil::broadcastToMatch()).
      progThe sequence to extend with the execution of the expression evaluation.
      debugContextOptional debug information
      optionsA list of flags to pass to the expression evaluator.
      Returns
      A tensor containing the elements resulting from the application of the expression across the tensors.

◆ max()

poplar::Tensor popops::max ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the maximum of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of max(a, b), where a and b are the corresponding elements of A and B tensors respectively.

◆ min()

poplar::Tensor popops::min ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the minimum of each element in A with the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of min(a, b), where a and b are the corresponding elements of A and B tensors respectively.

◆ mul()

poplar::Tensor popops::mul ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Multiply each element in A by the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a * b, where a and b are the corresponding elements of A and B tensors respectively.

◆ multiSlice() [1/2]

poplar::Tensor popops::multiSlice ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor offsets,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Take multiple slices from a base tensor.

The returned tensor will have a rank one greater than t. Its outer dimension will be offsets.dim(0). Note that dims refers to the dimensions of t. t can be created using createSliceableTensor() to ensure efficient mapping.

Parameters
graphThe Poplar graph.
tThe tensor being sliced.
offsetsThe offsets within t to be sliced.
dimsThe dimensions of t to be sliced.
sizesThe size of the update in each of the dimensions in dims.
progThe program to be extended.
planPlan describing how the operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.

◆ multiSlice() [2/2]

poplar::Tensor popops::multiSlice ( poplar::Graph graph,
const poplar::Tensor t,
poplar::ArrayRef< unsigned >  offsets,
std::size_t  dim,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Take multiple slices from a base tensor.

The returned tensor will have a rank one greater than t. Its outer dimension will be offsets.size(). Note that dim refers to a dimension of t.

Parameters
graphThe Poplar graph.
tThe tensor being sliced.
offsetsThe offsets within t to be sliced.
dimsThe dimension of t to be sliced.
progThe program to be extended.
debugContextOptional debug information.

◆ multiUpdate()

void popops::multiUpdate ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor s,
const poplar::Tensor offsets,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Update multiple slices in a tensor.

Parameters
graphThe Poplar graph.
tThe tensor being updated.
sThe slices to insert.
offsetsThe offsets within t to be updated.
dimsThe dimensions of t to be updated.
sizesThe size of the update in each of the dimensions in dims.
progThe program to be extended.
planPlan describing how the operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.

◆ multiUpdateAdd() [1/2]

void popops::multiUpdateAdd ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor s,
const poplar::Tensor offsets,
const poplar::Tensor scale,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Accumulate multiple slices in a tensor.

Parameters
graphThe Poplar graph.
tThe tensor being updated (must be rank 2).
sThe slices to accumulate.
offsetsThe offsets within t to be accumulated.
scaleThe scaling to apply to the update. The type of the tensor should be the same as that of t and s except for the case when t and s are of type HALF. In which case scale can be of type FLOAT or HALF.
dimsThe dimensions of t to be accumulated (must be rank 1).
sizesThe size of the accumulate in each of the dimensions in dims.
progThe program to be extended.
planPlan describing how the operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.

◆ multiUpdateAdd() [2/2]

void popops::multiUpdateAdd ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor s,
poplar::ArrayRef< unsigned >  offsets,
const poplar::Tensor scale,
std::size_t  dim,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Accumulate multiple slices in a tensor.

t, s must be of the same type

Parameters
graphThe Poplar graph.
tThe tensor being updated.
sThe slices to accumulate.
offsetsThe offsets within t to be accumulated.
scaleThe scaling to apply to the update. The type of the tensor should be the same as that of t and s except for the case when t and s are of type HALF. In which case scale can be of type FLOAT or HALF.
dimThe dimension of t to be accumulated.
progThe program to be extended.
debugContextOptional debug information.

◆ multiUpdateMax()

void popops::multiUpdateMax ( poplar::Graph graph,
const poplar::Tensor t,
const poplar::Tensor s,
const poplar::Tensor offsets,
const std::vector< std::size_t > &  dims,
const std::vector< std::size_t > &  sizes,
poplar::program::Sequence prog,
const SlicePlan plan,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext = {} 
)

Find maximum over multiple slices in a tensor.

t, s must have the same element type offsets[i] >= t.dim(0) are ignored.

Parameters
graphThe Poplar graph.
tThe tensor being updated (must be rank 2).
sThe slices to find maximum over.
offsetsThe offsets within t to find maximum over.
dimsThe dimensions of t to find maximum over (must be rank 1).
sizesThe size of the update in each of the dimensions in dims.
progThe program to be extended.
planPlan describing how the operation will be implemented.
optionsFlags controlling how the operation will be implemented.
debugContextOptional debug information.

◆ neg()

poplar::Tensor popops::neg ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the negation of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of -1 * a, where a is an element of A.

◆ neq()

poplar::Tensor popops::neq ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Check if each element in A is not equal to the corresponding element in B.

Parameters
graphThe graph to update.
AA tensor of elements.
BA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is the result of a != b, where a and b are the corresponding elements of A and B tensors respectively.

◆ normaliseImage()

poplar::Tensor popops::normaliseImage ( poplar::Graph graph,
poplar::program::Sequence seq,
poplar::Tensor  tIn,
float  inScale,
poplar::Tensor  offsets,
poplar::Tensor  scales,
const poplar::DebugContext debugContext = {} 
)

Pad a tensor to have 4 channel dimensions.

Each channel is normalised via:

 tIn[c] * inScale - offset[c]) * scale[c]

tIn must be mapped with a single region of complete pixels on each tile. createNormaliseImageInput() creates a variable that is suitably mapped.

UINT8 inputs are cast to HALF. Otherwise the output tensor follows the input type.

Parameters
graphThe graph containing the tensor.
seqThe sequence to which the normalisation programs will be added.
tInInput image. It must have an inner dimension of 3. and be UNSIGNED_CHAR, HALF or FLOAT.
inScaleInput scaling.
offsetsOffset for each channel. Must be shape {3} and must match the output type.
scalesScaling factor for each channel. Must be shape {3} and must match the output type.
debugContextDebugging context.

◆ operator<<()

std::ostream & popops::operator<< ( std::ostream &  os,
const Operation op 
)

Write op to output stream os.

The value written is the stringified enumeration, for example "ADD" or "MUL".

Returns
The original output stream.

◆ operator>>()

std::istream & popops::operator>> ( std::istream &  is,
Operation op 
)

Parse token from input stream is to op.

Valid input values are the stringified enumerations, for example "ADD" or "MUL".

Returns
The original input stream.

◆ outputGeneratedCodelet()

void popops::outputGeneratedCodelet ( const poplar::Target target,
const expr::Expr expr,
const std::vector< poplar::Tensor > &  ts,
const poplar::OptionFlags options,
std::ostream &  os 
)

Writes the generated codelet for the given expr and ts to os.

Parameters
targetThe target the graph is being constructed to work with.
exprThe expression to map across the tensors. The placeholders in the expressions will be substituted with corresponding elements from the tensors in ts.
tsThe list of tensors to map the expression across. If elements from these tensors are used in binary/ternary operations in the expression the numpy-style broadcast rules are used to match the shapes of the tensors (see poputil::broadcastToMatch()).
optionsA list of flags to pass to the expression evaluator. See map() function for details.
osThe stream to output generated codelet.

◆ pad() [1/4]

poplar::Tensor popops::pad ( const poplar::Tensor t,
const std::vector< std::ptrdiff_t > &  paddingLower,
const std::vector< std::ptrdiff_t > &  paddingUpper,
padding::Type  type 
)

Return a tensor with numpy-style padding added.

Parameters
tThe tensor to pad.
paddingLowerA vector specifying the amount of padding to add at the start of each dimension. Negative padding truncates.
paddingUpperA vector specifying the amount of padding to add at the end of each dimension. Negative padding truncates.
typeThe type of padding.
Returns
The tensor with padding added.

◆ pad() [2/4]

poplar::Tensor popops::pad ( const poplar::Tensor t,
std::ptrdiff_t  paddingLower,
std::ptrdiff_t  paddingUpper,
unsigned  dim,
padding::Type  type 
)

Return a tensor with numpy-style padding added to one dimension.

Parameters
tThe tensor to pad.
paddingLowerThe amount of padding to add at the start of the dimension. Negative padding truncates.
paddingUpperThe amount of padding to add at the end of the dimension. Negative padding truncates.
dimThe dimension to pad.
Returns
The tensor with padding added.

◆ pad() [3/4]

poplar::Tensor popops::pad ( poplar::Graph graph,
const poplar::Tensor t,
const std::vector< std::ptrdiff_t > &  paddingLower,
const std::vector< std::ptrdiff_t > &  paddingUpper,
float  val = 0.0f,
padding::MappingMethod  mappingMethod = padding::MappingMethod::ZERO 
)

Return a tensor with constant padding added.

Parameters
graphThe graph containing the tensor.
tThe tensor to pad.
paddingLowerA vector specifying the amount of padding to add at the start of each dimension. Negative padding truncates.
paddingUpperA vector specifying the amount of padding to add at the end of each dimension. Negative padding truncates.
valThe input tensor will be padded with this value.
mappingMethodThe method that should be used to map added padding elements.
Returns
The tensor with padding added.

◆ pad() [4/4]

poplar::Tensor popops::pad ( poplar::Graph graph,
const poplar::Tensor t,
std::ptrdiff_t  paddingLower,
std::ptrdiff_t  paddingUpper,
unsigned  dim,
float  val = 0.0f,
padding::MappingMethod  mappingMethod = padding::MappingMethod::ZERO 
)

Return a tensor with constant padding added to one dimension.

Parameters
tThe tensor to pad.
paddingLowerThe amount of padding to add at the start of the dimension. Negative padding truncates.
paddingUpperThe amount of padding to add at the end of the dimension. Negative padding truncates.
dimThe dimension to pad.
valThe input tensor will be padded with this value.
mappingMethodThe method that should be used to map added padding elements.
Returns
The tensor with padding added.

◆ popcount()

poplar::Tensor popops::popcount ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the number of 1 bits in each element of A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::popcount(a), where a is an element of A.

◆ pow()

poplar::Tensor popops::pow ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute each element in A to the power of the corresponding element in B.

Parameters
graphThe graph to update.
AThe tensor of bases.
BThe tensor of exponents.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is equal to pow(a, b), where a and b are the corresponding elements of A and B tensors respectively.

◆ reduce() [1/3]

poplar::Tensor popops::reduce ( poplar::Graph graph,
const poplar::Tensor in,
const poplar::Type outType,
const std::vector< std::size_t > &  dims,
ReduceParams  params,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Apply a reduction operation to a tensor.

scale and update are only valid with the ADD , SQUARE_ADD or LOG_ADD operations. LOG_ADD performs all arithmetic consistent with the input and output being log probabilities. In other words, the update is another log add operation and the scale is a log multiply operation.

Internally, this creates a new variable for the output then calls reduceWithOutput(). The type of the output will be outType.

The options parameter accepts the following:

  • accumType.interTile (float, half)

    The type to use for intermediate values between tiles. If the type specified is smaller than the output type then the option is ignored and the output type is used instead.

  • accumType.inVertex (float, half)

    The type to use for intermediate values within a vertex. If the type specified is smaller than the output type then the option is ignored and the output type is used instead.

If either of the above options are not set then the intermediate type will default to either the input tensor element type or float if the input is of type half and the reduction operation benefits from higher precision (for example, add).

The input and output types that are supported depend on the operation:

  • ADD, SQUARE_ADD, MUL: float->float, half->half, int->int, float->half, half->float
  • LOG_ADD : float->float, half->half, float->half, half->float
  • MAX, MIN: float->float, half->half, int->int
  • LOGICAL_AND, LOGICAL_OR: bool->bool
Parameters
graphThe graph to add the operation to.
inThe tensor to be reduced.
outTypeThe output type of the reduce operation.
dimsThe dimensions to reduce in.
progThe program sequence to add the operation to.
debugContextOptional debug information.

◆ reduce() [2/3]

poplar::Tensor popops::reduce ( poplar::Graph graph,
const poplar::Tensor in,
const poplar::Type outType,
const std::vector< std::size_t > &  dims,
ReduceParams  params,
std::vector< poplar::ComputeSet > &  css,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Apply a reduction operation to a tensor.

Deprecated:
The reduce overloads that expect a vector of compute sets are deprecated. Please use the reduceMany() function instead.

These are alternate forms that add their vertices to a vector of compute sets instead of a poplar::program::Sequence. The caller is expected to add each compute set to a poplar::program::Sequence (in a poplar::program::Execute) themselves, like this:

Sequence seq;
std::vector<ComputeSet> css;
auto A = reduce(..., css);
auto B = reduce(..., css);
for (const auto &cs : css) {
  seq.add(Execute(cs));

This allows you to do multiple reductions in parallel. Note that the reductions are not aware of each other, so it may be more efficient to concatenate tensors and do a single reduction instead if they have the same shape, operation, and input and output types.

scale and update are only valid with the ADD , SQUARE_ADD or LOG_ADD operations. LOG_ADD performs all arithmetic consistent with the input and output being log probabilities. In other words, the update is another log add operation and the scale is a log multiply operation.

Internally, this creates a new variable for the output then calls reduceWithOutput(). The type of the output will be outType.

The options parameter accepts the following:

  • accumType.interTile (float, half)

    The type to use for intermediate values between tiles. If the type specified is smaller than the output type then the option is ignored and the output type is used instead.

  • accumType.inVertex (float, half)

    The type to use for intermediate values within a vertex. If the type specified is smaller than the output type then the option is ignored and the output type is used instead.

If either of the above options are not set then the intermediate type will default to either the input tensor element type or float if the input is of type half and the reduction operation benefits from higher precision (for example, add).

The input and output types that are supported depend on the operation:

  • ADD, SQUARE_ADD, MUL: float->float, half->half, int->int, float->half, half->float
  • LOG_ADD : float->float, half->half, float->half, half->float
  • MAX, MIN: float->float, half->half, int->int
  • LOGICAL_AND, LOGICAL_OR: bool->bool
Parameters
graphThe graph to add the operation to.
inThe tensor to be reduced.
outTypeThe output type of the reduce operation.
dimsThe dimensions to reduce in.
progThe program sequence to add the operation to.
debugContextOptional debug information.

◆ reduce() [3/3]

poplar::Tensor popops::reduce ( poplar::Graph graph,
const poplar::Tensor in,
const std::vector< std::size_t > &  dims,
ReduceParams  params,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Apply a reduction operation to a tensor.

An alias for reduce(graph, in, in.elementType(), ...)

scale and update are only valid with the ADD , SQUARE_ADD or LOG_ADD operations. LOG_ADD performs all arithmetic consistent with the input and output being log probabilities. In other words, the update is another log add operation and the scale is a log multiply operation.

Internally, this creates a new variable for the output then calls reduceWithOutput(). The type of the output will be outType.

The options parameter accepts the following:

  • accumType.interTile (float, half)

    The type to use for intermediate values between tiles. If the type specified is smaller than the output type then the option is ignored and the output type is used instead.

  • accumType.inVertex (float, half)

    The type to use for intermediate values within a vertex. If the type specified is smaller than the output type then the option is ignored and the output type is used instead.

If either of the above options are not set then the intermediate type will default to either the input tensor element type or float if the input is of type half and the reduction operation benefits from higher precision (for example, add).

The input and output types that are supported depend on the operation:

  • ADD, SQUARE_ADD, MUL: float->float, half->half, int->int, float->half, half->float
  • LOG_ADD : float->float, half->half, float->half, half->float
  • MAX, MIN: float->float, half->half, int->int
  • LOGICAL_AND, LOGICAL_OR: bool->bool
Parameters
graphThe graph to add the operation to.
inThe tensor to be reduced.
outTypeThe output type of the reduce operation.
dimsThe dimensions to reduce in.
progThe program sequence to add the operation to.
debugContextOptional debug information.

◆ reduceMany()

void popops::reduceMany ( poplar::Graph graph,
const std::vector< SingleReduceOp > &  reductions,
std::vector< poplar::Tensor > &  outputs,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Perform many reductions (in parallel if possible).

Please see the documentation for reduce() for details of the common inputs.

Parameters
reductionsThe inputs to each reduction to perform. The outType attribute controls the element type of the output tensor if outputs is empty, otherwise it is ignored. If outputs is empty and useOutType is false then the output element type will be set to the same element type as the corresponding in tensor.
outputsThe tensors to store the output of the reductions. This may be empty in which case reduceMany will create the tensors. If the tile mapping is not set or not complete it will be set completely by this function.
Exceptions
poputils::poplibs_errorIf outputs is not empty then its size must exactly match the size of reductions else an exception will be thrown.
poputils::poplibs_errorIf outputs is empty and any reduction has params.update set to true then an exception will be thrown. outputs is required to perform an update reduction.

◆ reduceWithOutput()

void popops::reduceWithOutput ( poplar::Graph graph,
const poplar::Tensor in,
const poplar::Tensor out,
const std::vector< std::size_t > &  dims,
ReduceParams  params,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Apply a reduction operation to a tensor.

This is similar to reduce() but allows you to specify the output. If the tile mapping of out is not complete it will be set. Otherwise it won't be changed.

scale and update are only valid with the ADD , SQUARE_ADD or LOG_ADD operations. LOG_ADD performs all arithmetic consistent with the input and output being log probabilities. In other words, the update is another log add operation and the scale is a log multiply operation.

Internally, this creates a new variable for the output then calls reduceWithOutput(). The type of the output will be outType.

The options parameter accepts the following:

  • accumType.interTile (float, half)

    The type to use for intermediate values between tiles. If the type specified is smaller than the output type then the option is ignored and the output type is used instead.

  • accumType.inVertex (float, half)

    The type to use for intermediate values within a vertex. If the type specified is smaller than the output type then the option is ignored and the output type is used instead.

If either of the above options are not set then the intermediate type will default to either the input tensor element type or float if the input is of type half and the reduction operation benefits from higher precision (for example, add).

The input and output types that are supported depend on the operation:

  • ADD, SQUARE_ADD, MUL: float->float, half->half, int->int, float->half, half->float
  • LOG_ADD : float->float, half->half, float->half, half->float
  • MAX, MIN: float->float, half->half, int->int
  • LOGICAL_AND, LOGICAL_OR: bool->bool
Parameters
graphThe graph to add the operation to.
inThe tensor to be reduced.
outTypeThe output type of the reduce operation.
dimsThe dimensions to reduce in.
progThe program sequence to add the operation to.
debugContextOptional debug information.

◆ rem()

poplar::Tensor popops::rem ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the remainder of each element in A divided by the corresponding element in B.

Parameters
graphThe graph to update.
AThe tensor of dividends.
BThe tensor of divisors.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is equal to a % b, where a and b are the corresponding elements of A and B tensors respectively.

◆ round()

poplar::Tensor popops::round ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Round each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::round(a), where a is an element of A.

◆ rsqrt()

poplar::Tensor popops::rsqrt ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the reciprocal square root for each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of 1 / sqrt(a), where a is an element of A.

◆ scaledAddTo() [1/6]

void popops::scaledAddTo ( poplar::Graph graph,
poplar::Tensor  A,
float  scaleA,
poplar::Tensor  B,
float  scaleB,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Scale the elements of one tensor and add the scaled elements of another tensor to it.

The two scaling factors are constants.

Performs the calculations A = scaleA * A + scaleB * B

If A and B are of different types, B is first cast to the type of A and the operation performed.

Parameters
graphThe Poplar graph.
AThe destination tensor.
scaleAThe constant to multiply elements of A with before addition.
BThe second tensor to add elements from (must be of the same shape as A).
scaleBThe constant to multiply elements of B with before addition.
progA sequence program to which the code performing the add will be appended.
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scaledAddTo() [2/6]

void popops::scaledAddTo ( poplar::Graph graph,
poplar::Tensor  A,
float  scaleA,
poplar::Tensor  B,
float  scaleB,
poplar::program::Sequence prog,
const ScaledAddSpecialisation  speciality,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Scale the elements of one tensor and add the scaled elements of another tensor to it.

The two scaling factors are constants.

Performs the calculations A = scaleA' * A + scaleB * B where scaleA' is a function of scaleA specified by the "speciality" option.

If A and B are of different types, B is first cast to the type of A and the operation performed.

Parameters
graphThe Poplar graph.
AThe destination tensor.
scaleAThe constant to multiply elements of A with before addition.
BThe second tensor to add elements from (must be of the same shape as A).
scaleBThe constant to multiply elements of B with before addition.
progA sequence program to which the code performing the add will be appended.
specialityChoice of ScaledAdd expression formulation
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scaledAddTo() [3/6]

void popops::scaledAddTo ( poplar::Graph graph,
poplar::Tensor  A,
poplar::Tensor  B,
float  scaleB,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Add the elements of one tensor multiplied by a scalar to another tensor.

Performs the calculations A += scaleB * B

The operation is performed after casting B to the type of A.

Scaled add options

  • optimizeForSpeed (true, false) [=false]

    The scaledAdd vertices default to being optimized to aid memory allocation. To optimise them for speed instead, set this option to true.

  • scaleFloatToHalfTolerance (double) [=1e-6]

    Where the tensors A, B are of type half and a scaleB is provided as a float or a tensor of type float, it is possible to to implement the scaledAddTo in half precision if scaleB can be cast to half precision with acceptable accuracy. Otherwise full precision arithmetic can be used internally, but at the cost of speed. Floating point arithmetic will be selected if the relative error in casting is greater than the relative tolerance.
    Only applies to scaledAddTo() with scaleB.

Parameters
graphThe Poplar graph.
AThe destination tensor.
BThe second tensor to add elements from (must be of the same shape as A).
scaleBThe scalar to multiply elements of B with before addition.
progA sequence program to which the code performing the add will be appended.
debugContextOptional debug information.
optionsA list of flags to control optimizations.

◆ scaledAddTo() [4/6]

void popops::scaledAddTo ( poplar::Graph graph,
poplar::Tensor  A,
poplar::Tensor  B,
poplar::Tensor  scaleB,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Add the elements of one tensor each multiplied by a (scalar) tensor to another tensor.

Performs the calculations A += scaleB * B

The operation is performed after casting scaleB and B to the type of A.

Parameters
graphThe Poplar graph.
AThe destination tensor.
BThe second tensor to add elements from (must be of the same shape as A).
scaleBThe scalar tensor to multiply elements of B with before addition.
progA sequence program to which the code performing the add will be appended.
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scaledAddTo() [5/6]

void popops::scaledAddTo ( poplar::Graph graph,
poplar::Tensor  A,
poplar::Tensor  scaleA,
poplar::Tensor  B,
poplar::Tensor  scaleB,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Scale the elements of one tensor and add the scaled elements of another tensor to it.

The two scaling factors are (scalar) tensors.

Performs the calculations A = scaleA * A + scaleB * B

The operation is performed after casting scaleA, scaleB and B to the type of A.

Parameters
graphThe Poplar graph.
AThe destination tensor.
scaleAThe scalar tensor to multiply elements of A with before addition.
BThe second tensor to add elements from (must be of the same shape as A).
scaleBThe scalar tensor to multiply elements of B with before addition.
progA sequence program to which the code performing the add will be appended.
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scaledAddTo() [6/6]

void popops::scaledAddTo ( poplar::Graph graph,
poplar::Tensor  A,
poplar::Tensor  scaleA,
poplar::Tensor  B,
poplar::Tensor  scaleB,
poplar::program::Sequence prog,
const ScaledAddSpecialisation  speciality,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Scale the elements of one tensor and add the scaled elements of another tensor to it.

The two scaling factors are (scalar) tensors.

Performs the calculations A = scaleA' * A + scaleB * B where scaleA' is a function of scaleA specified by the "speciality" option.

The operation is performed after casting scaleA, scaleB and B to the type of A.

Parameters
graphThe Poplar graph.
AThe destination tensor.
scaleAThe scalar tensor to multiply elements of A with before addition.
BThe second tensor to add elements from (must be of the same shape as A).
scaleBThe scalar tensor to multiply elements of B with before addition.
progA sequence program to which the code performing the add will be appended.
specialityChoice of ScaledAdd expression formulation
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scaledSubtractFrom() [1/4]

void popops::scaledSubtractFrom ( poplar::Graph graph,
poplar::Tensor  A,
float  scaleA,
poplar::Tensor  B,
float  scaleB,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Scale the elements of one tensor and subtract the scaled elements of another tensor to it.

The two scaling factors are constants.

Performs the calculations A = scaleA * A - scaleB * B

If A and B are of different types, B is first cast to the type of A and the operation performed.

Parameters
graphThe Poplar graph.
AThe destination tensor.
scaleAThe constant to multiply elements of A with before subtraction.
BThe second tensor to subtract elements from (must be of the same shape as A).
scaleBThe constant to multiply elements of B with before subtraction.
progA sequence program to which the code performing the subtract will be appended.
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scaledSubtractFrom() [2/4]

void popops::scaledSubtractFrom ( poplar::Graph graph,
poplar::Tensor  A,
poplar::Tensor  B,
float  scaleB,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Subtract the elements of one tensor multiplied by a scalar from another tensor.

Performs the calculations A -= scaleB * B

The operation is performed after casting B to type A.

Parameters
graphThe Poplar graph.
AThe destination tensor.
BThe second tensor providing the elements to subtract (must be of the same shape as A).
scaleBThe scalar to multiply elements of B with before subtraction.
progA sequence program to which the code performing the add will be appended.
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scaledSubtractFrom() [3/4]

void popops::scaledSubtractFrom ( poplar::Graph graph,
poplar::Tensor  A,
poplar::Tensor  B,
poplar::Tensor  scaleB,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Subtract the elements of one tensor each multiplied by a (scalar) tensor from another tensor.

Performs the calculations A -= scaleB * B

The operation is performed after casting scaleB, and B to the type of A.

Parameters
graphThe Poplar graph.
AThe destination tensor.
BThe second tensor providing the elements to subtract (must be of the same shape as A).
scaleBThe scalar tensor to multiply elements of B with before subtraction.
progA sequence program to which the code performing the add will be appended.
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scaledSubtractFrom() [4/4]

void popops::scaledSubtractFrom ( poplar::Graph graph,
poplar::Tensor  A,
poplar::Tensor  scaleA,
poplar::Tensor  B,
poplar::Tensor  scaleB,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Scale the elements of one tensor and subtract the scaled elements of another tensor to it.

The two scaling factors are (scalar) tensors.

Performs the calculations A = scaleA * A - scaleB * B

The operation is performed after casting scaleA, scaleB and B to the type of A.

Parameters
graphThe Poplar graph.
AThe destination tensor.
scaleAThe scalar tensor to multiply elements of A with before subtraction.
BThe second tensor to subtract elements from (must be of the same shape as A).
scaleBThe scalar tensor to multiply elements of B with before subtraction.
progA sequence program to which the code performing the subtract will be appended.
debugContextOptional debug information.
optionsA list of flags to control optimizations. See scaledAddTo().

◆ scatter() [1/2]

void popops::scatter ( poplar::Graph graph,
const poplar::Tensor operand,
const poplar::Tensor indices,
const poplar::Tensor updates,
std::size_t  indexVectorDim,
std::vector< unsigned >  updateWindowDims,
std::vector< std::size_t >  insertWindowDims,
std::vector< unsigned >  scatterDimsToOperandDims,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

The scatter operation generates a result which is the value of the input array operand, with several slices (at indices specified by indices) updated with the values in updates.

Parameters
graphThe Poplar graph.
operandArray to be scattered into.
indicesArray containing the starting indices of the slices that must be scattered to.
updatesArray containing the values that must be used for scattering.
indexVectorDimThe dimension in indices that contains the starting indices.
updateWindowDimsThe set of dimensions in updates shape that are window dimensions.
insertWindowDimsThe set of window dimensions that must be inserted into updates shape.
scatterDimsToOperandDimsA dimensions map from the scatter indices to the operand index space. This array is interpreted as mapping i to scatterDimsToOperandDims[i]. It has to be one-to-one and total.
progThe program to be extended.
debugContextOptional debug information.
Note
This is a near direct port of https://www.tensorflow.org/xla/operation_semantics#scatter from tensorflow/compiler/xla/service/scatter_expander.cc

◆ scatter() [2/2]

void popops::scatter ( poplar::Graph graph,
const poplar::Tensor operand,
const poplar::Tensor indices,
const poplar::Tensor updates,
std::size_t  indexVectorDim,
std::vector< unsigned >  updateWindowDims,
std::vector< std::size_t >  insertWindowDims,
std::vector< unsigned >  scatterDimsToOperandDims,
UpdateComputationFunc &  updateComputation,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Similar to the above scatter(), but allows for a user defined update computation.

This computation is used to combine the existing values in the input tensor and the updates during the scatter.

Parameters
graphThe Poplar graph.
operandArray to be scattered into.
indicesArray containing the starting indices of the slices that must be scattered to.
updatesArray containing the values that must be used for scattering.
indexVectorDimThe dimension in indices that contains the starting indices.
updateWindowDimsThe set of dimensions in updates shape that are window dimensions.
insertWindowDimsThe set of window dimensions that must be inserted into updates shape.
scatterDimsToOperandDimsA map of dimensions from the scatter indices to the operand index space. This array is interpreted as mapping i to scatterDimsToOperandDims[i]. It has to be one-to-one and total.
updateComputationComputation to be used for combining the existing values in the input tensor and the updates during scatter.
progThe program to be extended.
debugContextOptional debug information.
Note
The first tensor parameter that is passed into the updateComputation will always be the current value from the operand tensor and the second parameter will always be the value from the updates tensor. This is important specifically for cases when the updateComputation is not commutative.

◆ select()

poplar::Tensor popops::select ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
const poplar::Tensor C,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Populate the returned tensor with elements from A or B depending on the corresponding element of C.

That is, for each element in the output compute c ? a : b, where a, b and c are the corresponding elements in the tensors A, B, C respectively.

Parameters
graphThe graph to update.
AOne of the tensors containing the elements to select from.
BOne of the tensors containing the elements to select from.
CThe tensor containing the elements to use as predicates.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor containing the elements from A where the corresponding elements in C were not equal to zero and containing the elements from B where the corresponding elements in C were zero.

◆ selectScalarFromRows()

poplar::Tensor popops::selectScalarFromRows ( poplar::Graph graph,
const poplar::Tensor params,
const poplar::Tensor indices,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

For each row in the 2D tensor params, select a single scalar value.

Aggregate the resulting scalars into a 1D tensor.

Parameters
graphThe Poplar graph.
paramsA 2D tensor, the element type must be either float or half.
indicesA 1D tensor, the element type must be unsigned integer.
progThe program to be extended.
debugContextOptional debug information.

The size of the indices tensor must be equal to the size of dimension 0 of params. The ith element of indices represents an index in the ith row of the params tensor.

If ith element of the indices tensor is less than 0 or greater than the width of params then a NaN is stored into the ith element of the output. If the ith element of the indices tensor is equal to MASKED_LABEL_CODE then zero is stored into the ith element of the output.

Returns
A 1D tensor containing in the ith position the scalar params[indices[i]].

◆ sequenceSlice()

void popops::sequenceSlice ( poplar::Graph graph,
const poplar::Tensor tIn,
const poplar::Tensor tOut,
const poplar::Tensor tN,
const poplar::Tensor tInOffset,
const poplar::Tensor tOutOffset,
bool  zeroUnused,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Slice a 2d tensor based on offsets specified by a tensor.

Typically this is used to copy subsequences of one tensor to another. The outermost dimension is sliced; tOut[tOutOffset:tOutOffset+tN][...] = tIn[tInOffset:tInOffset+tN][...] for each entry in tN/tInOffset/tOutOffset; entries after the first tN==0 may be ignored. Unreferenced elements of tOut are zeroed if zeroUnused is set. The same output element should not be written by multiple inputs.

tIn and tOut must have rank >=2. The outer dimension is sliced; the product of the inner dimensions must match. tInOffset, tOutOffset and tN must be 1d and the same size.

Parameters
graphThe Poplar graph.
tInThe source tensor.
tOutThe destination tensor.
tNThe number of elements to copy.
tInOffsetFirst element read from tIn.
tOutOffsetFirst element written in tOut.
zeroUnusedWhether to zero unreferenced tOut elements.
progThe program to be extended.
debugContextOptional debug information.

◆ shiftLeft()

poplar::Tensor popops::shiftLeft ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Shift the elements of A left by the corresponding elements of B.

Parameters
graphThe graph to update.
AThe tensor of elements which to left-shift.
BThe tensor of elements that describe the amount to left-shift A by.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is equal to a << b, where a and b are the corresponding elements of A and B tensors respectively.

◆ shiftRight()

poplar::Tensor popops::shiftRight ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Shift the elements of A right by the corresponding elements of B.

Parameters
graphThe graph to update.
AThe tensor of elements which to right-shift.
BThe tensor of elements that describe the amount to right-shift by. A.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is equal to a >> b (without sign extension), where a and b are the corresponding elements of A and B tensors respectively.

◆ shiftRightSignExtend()

poplar::Tensor popops::shiftRightSignExtend ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Shift the elements of A right with sign extension by the corresponding elements of B.

Parameters
graphThe graph to update.
AThe tensor of elements which to right-shift.
BThe tensor of elements that describe the amount to right-shift A by.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is equal to a >> b with sign extension, where a and b are the corresponding elements of A and B tensors respectively.

◆ sigmoid()

poplar::Tensor popops::sigmoid ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the sigmoid (logistic) function for each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of 1 / (1 + exp(-x)), where a is an element of A.

◆ signum()

poplar::Tensor popops::signum ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the signum of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is one of -1, 0 or +1 if the corresponding element in A was less than, equal to or greater than 0 respectively.

◆ sin()

poplar::Tensor popops::sin ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the sine of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::sin(a), where a is an element of A.

◆ sort()

poplar::Tensor popops::sort ( poplar::Graph graph,
const poplar::Tensor t,
unsigned  dim,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)
Deprecated:
deprecated Use popops::topK() instead.

Sort a tensor along the given dimension.

This will return a tensor that is a permutation of the input tensor v with all the elements of the 1D slices in the chosen dimension in ascending order.

This aims to match TensorFlow's XLA sort: https://www.tensorflow.org/xla/operation_semantics#sort

Parameters
graphThe Poplar graph.
tThe source tensor.
dimThe dimension to sort on.
progThe program to be extended.
debugContextOptional debug information.
Returns
A tensor which is a permutation of t such that all elements in the given dimension are in order.
Exceptions
poputil::poplibs_errorIf dim is not a valid dimension of v.

◆ sortInPlace()

void popops::sortInPlace ( poplar::Graph graph,
const poplar::Tensor t,
unsigned  dim,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)
Deprecated:
deprecated Use popops::topK() instead.

In-place sort a tensor along the given dimension.

This will permute the input tensor so that all the elements of 1D slices in the chosen dimension are in ascending order.

Parameters
graphThe Poplar graph.
tThe source tensor to be sorted.
dimThe dimension to sort on.
progThe program to be extended.
debugContextOptional debug information.
Exceptions
poputil::poplibs_errorIf dim is not a valid dimension of v.

◆ sortKeyValue()

poplar::Tensor popops::sortKeyValue ( poplar::Graph graph,
const poplar::Tensor k,
const poplar::Tensor v,
unsigned  dim,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)
Deprecated:
deprecated Use popops::topKKeyValue() instead.

Sort a tensor by a key tensor along the given dimension.

This will return a tensor that is a permutation of the input tensor v with the property that all 1D slices in the chosen dimensions are in ascending order with respect to the key tensor k.

This aims to match TensorFlow's XLA sort: https://www.tensorflow.org/xla/operation_semantics#sort

Parameters
graphThe Poplar graph.
kThe key tensor to sort on.
vThe value tensor to be sorted.
dimThe dimension to sort on.
progThe program to be extended.
debugContextOptional debug information.
Returns
A tensor which is a permutation of v such that it is in order with respect to the tensor k in the given dimension.
Note
If k and v alias, the result is undefined.
Exceptions
poputil::poplibs_errorIf dim is not a valid dimension of v.
poputil::poplibs_errorIf v and k are not the same shape.

◆ sortKeyValueInPlace()

void popops::sortKeyValueInPlace ( poplar::Graph graph,
const poplar::Tensor k,
const poplar::Tensor v,
unsigned  dim,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)
Deprecated:
deprecated Use popops::topKKeyValue() instead.

In-place sort a given tensor by a key tensor along the given dimension.

This will permute the key and value tensors so that all the elements of the 1D slices in the chosen dimension are in ascending order with respect to the key tensor.

Parameters
graphThe Poplar graph.
kThe key tensor to sort on.
vThe value tensor to be sorted.
dimThe dimension to sort on.
progThe program to be extended.
debugContextOptional debug information.
Note
The k tensor is also sorted by this in-place operation.
If the k tensor and the v tensor alias, the result is undefined.
Exceptions
poputil::poplibs_errorIf dim is not a valid dimension of v.
poputil::poplibs_errorIf v and k are not the same shape.

◆ sqrt()

poplar::Tensor popops::sqrt ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the square-root for each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::sqrt(a), where a is an element of A.

◆ square()

poplar::Tensor popops::square ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the square for each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of x * x, where a is an element of A.

◆ sub()

poplar::Tensor popops::sub ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Subtract the elements of B from A and return the result in a new tensor.

Parameters
graphThe graph to update.
AThe tensor of elements which will be subtracted from.
BThe tensor of elements to subtract from A.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information.
optionsElement-wise options. See map().
Returns
A tensor where each element is equal to a - b, where a and b are the corresponding elements of A and B tensors respectively.

◆ tan()

poplar::Tensor popops::tan ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the tangent of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::tan(a), where a is an element of A.

◆ tanh()

poplar::Tensor popops::tanh ( poplar::Graph graph,
const poplar::Tensor A,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Compute the hyperbolic tangent of each element in A.

Parameters
graphThe graph to update.
AA tensor of elements.
progThe sequence to extend with the execution of the expression evaluation.
debugContextOptional debug information
optionsElement-wise options. See map().
Returns
A tensor where each element is equivalent to the result of std::tanh(a), where a is an element of A.

◆ topK()

poplar::Tensor popops::topK ( poplar::Graph graph,
poplar::program::Sequence prog,
const poplar::Tensor t,
const TopKParams params,
const poplar::DebugContext debugContext = {} 
)

Return the top k values in the innermost dimension of a tensor.

Parameters
graphThe Poplar graph to add the operation to.
progThe Poplar sequence to add the operation to.
tThe tensor in which to find the top-k values in the innermost dimension.
paramsThe parameters of the top k.
debugContextOptional debug information.
Returns
A tensor with the top k values found in the innermost dimension of t.

◆ topKKeyValue()

std::pair< poplar::Tensor, poplar::Tensor > popops::topKKeyValue ( poplar::Graph graph,
poplar::program::Sequence prog,
const poplar::Tensor keys,
const poplar::Tensor values,
const TopKParams params,
const poplar::DebugContext debugContext = {} 
)

Return the top k values in the innermost dimension of a tensor along with the permutation of another tensor with respect to the values.

Parameters
graphThe Poplar graph to add the operation to.
progThe Poplar sequence to add the operation to.
keyThe tensor in which to find the top-k values in the innermost dimension.
valueA tensor with the same shape as key for which to get the permutation with respect to key.
paramsThe parameters of the top k.
debugContextOptional debug information.
Returns
A pair of tensors. The first contains the top k values found in the innermost dimension of key. The second contains the permutation of the tensor value with respect to the tensor key.

◆ topKWithPermutation()

std::pair< poplar::Tensor, poplar::Tensor > popops::topKWithPermutation ( poplar::Graph graph,
poplar::program::Sequence prog,
const poplar::Tensor t,
const TopKParams params,
const poplar::DebugContext debugContext = {} 
)

Return the top k values in the innermost dimension of a tensor along with the indices of those values in the input tensor in the innermost dimension.

Parameters
graphThe Poplar graph to add the operation to.
progThe Poplar sequence to add the operation to.
tThe tensor in which to find the top-k values in the innermost dimension.
paramsThe parameters of the top k.
debugContextOptional debug information.
Returns
A pair of tensors. The first contains the top k values found in the innermost dimension of t. The second contains the indices of those values in the innermost dimension of t in the original input.

◆ updateScalarInRows()

void popops::updateScalarInRows ( poplar::Graph graph,
const poplar::Tensor params,
const poplar::Tensor indices,
poplar::program::Sequence program,
const poplar::DebugContext debugContext = {} 
)

Update in-place one scalar per row of the tensor params.

For each row, the index of the value to update is specified by the tensor indices. If the index from indices is equal to MASKED_LABEL_CODE then no update is carried out.

Pseudo-code:

for each row r
if indices[r] != MASKED_LABEL_CODE
params[r][indices[r]] = params[r][indices[r]] - 1.f
#define MASKED_LABEL_CODE
Code point for masked index (an index to be ignored).
Definition: EncodingConstants.hpp:12

If the ith index is less than 0 or greater than the size of the row then the whole row of the param tensor is set to NaN. This is to match the interface of the backward phase of tf.nn.sparse_softmax_cross_entropy_with_logits, see https://www.tensorflow.org/api_docs/python/tf/nn/sparse_softmax_cross_entropy_with_logits

Parameters
graphThe Poplar graph.
paramsThe 2D tensor to be updated, the element type must be either float or half.
indices1D tensor, the element-type must be unsigned integer.
programThe program to be extended.
debugContextOptional debug information.

◆ varianceToInvStdDev() [1/2]

poplar::Tensor popops::varianceToInvStdDev ( poplar::Graph graph,
const poplar::Tensor A,
const poplar::Tensor B,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)
inline

Convert variance to inverse standard deviation.

Parameters
graphThe graph to update.
AThe source tensor.
BThe destination tensor.
progThe sequence to extend with the execution of conversion.
debugContextOptional debug information.
Returns
A tensor where each element is the inverse of standard deviation. Each element is the result of b = sqrt(1 / a), where a and b are the corresponding elements of A and B tensors respectively, and where A represents the variance and B the inverse standard deviation.

◆ varianceToInvStdDev() [2/2]

poplar::Tensor popops::varianceToInvStdDev ( poplar::Graph graph,
const poplar::Tensor src,
const poplar::Tensor epsilon,
poplar::program::Sequence prog,
const poplar::Type  dstType = poplar::HALF,
const poplar::DebugContext debugContext = {} 
)

Convert variance to inverse standard deviation.

Parameters
graphThe graph to update.
srcThe source tensor.
epsilonA tensor initialised with the epsilon parameter used in conversion. Must have a single element and have the same type as the input type. Alternatively a float value can be used and the appropriate tensor will be created.
progThe sequence to extend with the execution of conversion.
dstTypeThe type of the tensor to be output. Must be HALF or equal to the input type.
debugContextOptional debug information
Returns
A tensor where each element is the inverse of standard deviation. Each element is the result of b = sqrt(1 / a), where a and b are the corresponding elements of src and the result tensor respectively.

◆ zero() [1/4]

void popops::zero ( poplar::Graph graph,
const poplar::Tensor t,
const std::vector< std::vector< poplar::Interval > > &  mapping,
poplar::ComputeSet  zeroCS 
)

Append vertices to compute set zeroCS which zeroes elements in mapping of tensor t which reside on tiles represented with mapping.

Parameters
graphThe graph that the operation will be added to.
tThe tensor whose elements are to be set to zero.
mappingThe tensor's region mapping per tile. Each element describes a region mapping of a tile (ordered). For example, mapping[0] is tile 0's region mapping for tensor t.
zeroCSThe compute set to add the operation to.

◆ zero() [2/4]

void popops::zero ( poplar::Graph graph,
const poplar::Tensor t,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {} 
)

Append programs to program sequence prog which zeroes all elements of tensor t.

Parameters
graphThe graph that the operation will be added to.
tThe tensor whose elements are to be set to zero.
progThe Poplar program sequence to append the operation to.
debugContextOptional debug information.

◆ zero() [3/4]

void popops::zero ( poplar::Graph graph,
const poplar::Tensor t,
unsigned  tile,
poplar::ComputeSet  zeroCS 
)

Append vertices to compute set zeroCS which zeroes all elements of tensor t which reside on tile.

Parameters
graphThe graph that the operation will be added to.
tThe tensor whose elements are to be set to zero.
tileThe tile which the tensor is mapped to.
zeroCSThe compute set to add the operation to.

◆ zero() [4/4]

void popops::zero ( poplar::Graph graph,
poplar::Tensor  t,
const std::vector< poplar::Interval > &  tileRegions,
unsigned  tile,
poplar::ComputeSet  zeroCS 
)

Append vertices to compute set zeroCS which zeroes elements in tileRegions of tensor t which reside on tile.

Parameters
graphThe graph that the operation will be added to.
tThe tensor whose elements are to be set to zero.
tileRegionsThe region mapping of the tensor on tile.
tileThe tile which the regions relate to.
zeroCSThe compute set to add the operation to.