Poplar and PopLibs
|
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 ¶ms, 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 ¶ms, 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 ¶ms, const poplar::DebugContext &debugContext={}) |
Return the top k values in the innermost dimension of a tensor. More... | |
std::pair< poplar::Tensor, poplar::Tensor > | topKKeyValue (poplar::Graph &graph, poplar::program::Sequence &prog, const poplar::Tensor &keys, const poplar::Tensor &values, const TopKParams ¶ms, 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::Tensor > | topKWithPermutation (poplar::Graph &graph, poplar::program::Sequence &prog, const poplar::Tensor &t, const TopKParams ¶ms, 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 ¶ms, 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... | |
Common functions, such as elementwise and reductions.
|
strong |
Type of operation to use in a reduction.
See reduce() for example use.
|
strong |
|
inline |
Compute the absolute value of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::abs(a)
, where a
is an element of A
.
|
inline |
Add each element in A
to the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a + b
, where a
and b
are the corresponding elements of A
and B
tensors respectively. 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.
graph | The Poplar graph. |
A | The boolean tensor. |
prog | The program sequence to add this operation to. |
debugContext | Optional debug information. |
poputil::poplibs_error | If the elements of A are not booleans. |
|
inline |
Compute the arc-sine of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::asin(a)
, where a
is an element of A
.
|
inline |
Compute the two argument arctangent of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
atan2(a, b)
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the bitwise AND of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a & b
, where a
and bare
the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the bitwise NOT operation for each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
~a
, where a
is an element of A
.
|
inline |
Compute the bitwise OR of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a | b
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the bitwise XNOR of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
!(a ^ b)
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the bitwise XOR of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a ^ b
, where a
and b
are the corresponding elements of A
and B
tensors respectively. 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.
graph | The graph that the operation will be added to. |
src | Source tensor to cast. |
dstType | The type of the destination tensor. |
metadata | A 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. |
prog | Program to add the cast operation to. |
debugContext | Optional debug information. |
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.
graph | The graph that the operation will be added to. |
src | Source tensor to cast. |
dstType | The type of the destination tensor. |
prog | Program to add the cast operation to. |
debugContext | Optional debug information. |
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.
graph | The graph that the operation will be added to. |
src | Source tensor. |
dstType | Destination type. |
metadata | A 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. |
cs | Compute set to add the vertices to. |
debugContext | Optional debug information. |
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.
graph | The graph that the operation will be added to. |
src | Source tensor. |
dstType | Destination type. |
cs | Compute set to add the vertices to. |
debugContext | Optional debug information. |
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.
graph | The graph that the operation will be added to. |
src | Source tensor. |
dst | Destination tensor. |
debugContext | Optional debug information. |
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()
graph | The graph that the operation will be added to. |
src | Source tensor. |
dst | Destination tensor. |
cs | Compute set to add the vertices to. |
|
inline |
Compute the cube-root for each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::cbrt(a)
, where a
is an element of A
.
|
inline |
Compute the ceiling of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::ceil(a)
, where a
is an element of A
. 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
graph | The graph that the operation will be added to. |
input | Input tensor. |
outputType | Output type after the cast operation. |
tolerance | Allowed tolerance in error from cast operation. |
prog | Program to add the check onto. |
debugContext | Optional debug information. |
tolerance
. poputil::poplibs_error | If either input or outputType are not either half or float. |
|
inline |
Check that the host compile-time type constType
is compatible with the run-time IPU type elementType
.
elementType | The run-time IPU type. |
constant | Unused. |
constType | The host compile-time type. |
std::runtime_error | If the types are not compatible. |
|
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.
graph | The graph to update. |
A | The tensor containing the elements to clamp. |
B | The tensor containing the elements to use as minimums. |
C | The tensor containing the elements to use as maximums. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
|
inline |
Compute the cosine of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::cos(a)
, where a
is an element of A
. 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:
graph | The graph the loop program will be added to. |
count | The loop count tensor, available to the body program with element type INT or UNSIGNED_INT. Value initialised by this function. |
initialCount | Initial counter value. |
countLimit | Count limit tensor. |
countStep | The increment added to the count tensor on each loop pass. |
body | The loop body program to run on each loop pass. |
debugContext | Optional debug information. |
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:
graph | The graph the loop program will be added to. |
initialCount | Initial counter value. |
countLimit | Count limit tensor. |
countStep | The increment added to the count tensor on each loop pass. |
body | The loop body program to run on each loop pass. |
debugContext | Optional debug information. |
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:
graph | The graph the loop program will be added to. |
begin | Initial counter value. |
end | Counter end value (exclusive). |
step | The increment added on each loop pass (must be greater than zero). |
body | The loop body program to run on each loop pass. |
debugContext | Optional debug information. |
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:
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
.)
graph | The graph the loop program will be added to. |
count | Number of loop iterations to execute. |
body | The loop body program to run on each loop pass. |
debugContext | Optional debug information. |
|
inline |
Compute the number of binary leading zeros of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a ? __builtin_clz(a) : 32
, where a
is an element of A
. 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.
graph | The Poplar graph. |
type | The data type of the required tensor. |
inputShape | The desired shape of the input. |
sliceSizes | sliceSizes [i] is the bounds for the slice on dimension i . |
startIndexMap | A map that describes how to map indices in indices in gather() to legal indices into the input. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
type | The data type of the required tensor. |
operandShape | The desired shape of the input. |
axis | The axis that will be gathered on. |
params | The same parameters as used by the gather(). |
debugContext | Optional debug information. |
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
.
graph | The Poplar graph. |
groupSize | The size of the group |
dims | The dimensions of a tensor to be sliced/updated that will be sliced/updated using these indices. |
numIndices | The number of indices this tensor should contain |
plan | Plan describing how the slicing/updating operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
type | The type of the elements. |
groupSize | The group size. |
shape | The shape of the tensor to be slice/updated. |
dims | The dimensions of the tensor that will be slice/updated. |
sizes | The size of the slice in each of the dimensions. |
plan | Plan describing how the slicing/updating operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
groupSize
as the first dimension and the remaining dimensions as in shape
. 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.
graph | The Poplar graph. |
type | The type of the elements. |
groupSize | The group size |
shape | The shape of the tensor to be slice/updated. |
dims | The dimensions of the tensor that will be sliced/updated. |
sizes | The number of elements of each dimension in dims that will be sliced/updated. |
numIndices | The number of slices this tensor should contain. |
plan | Plan describing how the slicing/updating operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph to add the tensor to. |
type | The element type of the tensor created. |
shape | The hape of created tensor. |
isRead | If 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. |
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.
graph | The graph to add the tensor to. |
type | The element type of the tensor created. |
shape | The shape of the tensor created. |
isRead | If 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. |
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.
graph | The Poplar graph. |
dims | The dimensions of a tensor to be sliced/updated that will be sliced/updated using these indices. |
numIndices | The number of indices this tensor should contain |
plan | Plan describing how the slicing/updating operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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.
graph | The graph to which the tensor will be added. |
type | The type of the elements. Must be UNSIGNED_CHAR , HALF or FLOAT . |
shape | Required tensor shape. Must have an inner dimension of three. |
debugContext | Debugging context. |
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.
graph | A graph to add the tensor to and which the inputs belong to. |
inputs | List of input tensors for the element-wise operation. |
outputType | The element type of the tensor. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
type | The type of the elements. |
shape | The shape of the tensor to be slice/updated. |
dims | The dimensions of the tensor that will be slice/updated. |
sizes | The size of the slice in each of the dimensions. |
plan | Plan describing how the slicing/updating operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
shape
that is suitably mapped. 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.
graph | The Poplar graph. |
type | The type of the elements. |
shape | The shape of the tensor to be slice/updated. |
dims | The dimensions of the tensor that will be slice/updated. |
sizes | The size of the slice in each of the dimensions. |
minGrainSize | The minimum elements per slice mapped to each tile |
debugContext | Optional debug information. |
shape
that is suitably mapped 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.
graph | The Poplar graph. |
s | The reference slice. |
dims | The dimensions of the returned tensor that will be sliced. |
numSlices | The number of independent slices in each sliced dimension. |
debugContext | Optional debug information. |
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
.
graph | The Poplar graph. |
t | The tensor to be updated. |
dims | The dimensions of the tensor that will be sliced/updated. |
sizes | The number of elements of each dimension in dims that will be sliced/updated. |
numIndices | The number of slices this tensor should contain. |
plan | Plan describing how the slicing/updating operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
type | The type of the elements. |
shape | The shape of the tensor to be slice/updated. |
dims | The dimensions of the tensor that will be sliced/updated. |
sizes | The number of elements of each dimension in dims that will be sliced/updated. |
numIndices | The number of slices this tensor should contain. |
plan | Plan describing how the slicing/updating operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph to add the tensor to. |
type | The Poplar type of elements in the returned tensor. |
shape | The shape of the returned tensor. |
params | The parameters of the top k that the returned tensor will be used as input to. |
debugContext | Optional debug information. |
shape
and full tile mapping.
|
inline |
Divide each element in A
by the corresponding element in B
.
graph | The graph to update. |
A | The tensor of dividends. |
B | The tensor of divisors. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a / b
, where a
and b
are the corresponding elements of A
and B
tensors respectively. 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.
graph | The Poplar graph. |
t | The source tensor. |
offset | A tensor of offsets at which the output is extracted. |
dims | The dimensions of t to slice. |
sizes | The size of the slice in each of the dimensions in dims . |
prog | The program to be extended |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
output | The output tensor, This should ideally be created with createSliceTensor to maximise efficiency, |
t | The source tensor. |
offset | A tensor of offsets at which the output is extracted. |
dims | The dimensions of t to slice. |
sizes | The size of the slice in each of the dimensions in dims . |
prog | The program to be extended |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
t | The tensor to update. |
s | The updates. |
offset | The offset within t to be updated. |
dims | The dimensions to be dynamically updated. |
sizes | The size of the update in each of the dimensions in dims . |
prog | The program to be extended. |
debugContext | Optional debug information. |
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
.
graph | The graph to add the tensor and any vertices needed for the encoding to. |
encoded | Tensor to encode output to. |
indices | 1-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. |
prog | Sequence which the programs that perform the encoding are added to. |
debugContext | Optional debug information. |
poputil::poplibs_error | If encoded is not two dimensional. |
poputil::poplibs_error | If indices and encoded do not have the same number of rows. |
poputil::poplibs_error | If elements of indices are not an integer type. |
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
.
graph | The graph to add the tensor and any vertices needed for the encoding to. |
encoded | Tensor to encode output to. |
indices | 1-dimensional tensor containing indices to encode as one-hot vectors. |
prog | Sequence which the programs that perform the encoding are added to. |
debugContext | Optional debug information. |
on | Value which represents the "On" state in the one hot encoded output. |
off | Value which represents the "Off" state. |
poputil::poplibs_error | If encoded is not two dimensional. |
poputil::poplibs_error | If indices and encoded do not have the same number of rows. |
poputil::poplibs_error | If elements of indices are not an integer type. |
|
inline |
Check if each element in A
is equal to the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a == b
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the error function of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::erf(a)
, where a
is an element of A
.
|
inline |
Compute the exponential of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::exp(a)
, where a
is an element of A
.
|
inline |
Compute the exponential of each element in A
minus one.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::expm1(a)
, where a
is an element of A
. 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
.
graph | The graph that the operation will be added to. |
t | The tensor whose elements are to be set to zero. |
mapping | The 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. |
fillCS | Compute set to add the operation into. |
fillValue | The value to fill t with. |
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
.
fillValue
must be compatible with the element type of t
.graph | The graph that the operation will be added to. |
t | The tensor whose elements are to be filled. |
prog | Poplar program sequence to append the operation onto. |
fillValue | The value to fill t with. |
debugContext | Optional debug information. |
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
.
graph | The graph that the operation will be added to. |
t | The tensor whose elements are to be set to zero. |
tile | Tile on which the tensor is mapped to. |
fillCS | Compute set to add the operation into. |
fillValue | The value to fill t with. |
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
.
graph | The graph that the operation will be added to. |
t | The tensor whose elements are to be set to zero. |
tileRegions | Region mapping of the tensor on tile . |
tile | Tile which the regions relate to. |
fillCS | Compute set to add the operation into. |
fillValue | The value to fill t with. |
|
inline |
Compute the floor of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::floor(a)
, where a
is an element of A
. 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().
graph | The Poplar graph. |
input | The tensor we are gathering from. |
indices | Tensor containing the starting indices of the slices we gather. |
indexVectorDim | The dimension in indices that "contains" the starting indices. |
offsetDims | The set of dimensions in the output shape that offset into a tensor sliced from input . |
sliceSizes | sliceSizes [i] is the bounds for the slice on dimension i . |
collapsedSliceDims | The set of dimensions in each slice that are collapsed away. These dimensions must have size 1. |
startIndexMap | A map that describes how to map indices in indices to legal indices into input . |
prog | The program sequence to add this operation to. |
debugContext | Optional debug information. |
indexVectorDim == indices.rank()
, the indices are interpreted as scalar values.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}
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().
graph | The Poplar graph. |
input | The tensor we are gathering from of rank x. |
indices | Tensor containing the indices of the slices we gather of rank y. |
axis | The axis to gather on. The axis must be less than x. |
prog | The program sequence to add this operation to. |
params | Parameters for the form of the gather. |
debugContext | Optional debug information. |
|
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.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
geluErf(a)
, where a
is an element of A
. 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.
graph | The Poplar graph. |
t | The source tensor. |
dims | The dimensions of t to slice. |
sizes | The size of the slice in each of the dimensions in dims . |
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.
graph | The Poplar graph. |
t | The tensor being sliced. |
offsets | The offsets within t to be sliced. |
dims | The dimensions of t for each group. |
sizes | The size of the update in each of the dimensions in dims . |
prog | The program to be extended. |
plan | Plan describing how the operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
t | The tensor being updated. |
s | The slices to insert. |
offsets | The offsets within t to be updated. |
dims | The dimensions of each group of t to be updated. |
sizes | The size of the update in each of the dimensions in dims . |
prog | The program to be extended. |
plan | Plan describing how the operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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
graph | The Poplar graph. |
t | The tensor being updated (must be rank 3). |
s | The slices to accumulate. |
offsets | The offsets within t to be accumulated. |
scale | The 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. |
dims | The dimensions of of each group to be accumulated. |
sizes | The size of the accumulate in each of the dimensions in dims . |
prog | The program to be extended. |
plan | Plan describing how the operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
t | The tensor being updated (must be rank 2). |
s | The slices to find maximum over. |
offsets | The offsets within t to find maximum over. |
dims | The dimensions of each group of t to find maximum over (must be rank 1). |
sizes | The size of the update in each of the dimensions in dims . |
prog | The program to be extended. |
plan | Plan describing how the operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
|
inline |
Check if each element in A
is greater than the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a > b
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Check if each element in A
is greater than or equal to the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
a >= b
, where a
and b
are the corresponding elements of A
and B
tensors respectively. 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.
graph | The graph to add the tensor and any vertices to. |
src | The input tensor, the type must be floating point. |
prog | Sequence to add programs to, which perform the check. |
debugContext | Optional debug information. |
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.
graph | The graph to add the tensor and any vertices to. |
src | The input tensor, the type must be floating point. |
prog | Sequence to add programs to, which perform the check. |
debugContext | Optional debug information. |
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]
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.
graph | The Poplar graph. |
input | The input tensor on which to gather histogram statistics. |
levels | The levels defining the comparisons to carry out in generating the histogram output. |
absoluteOfInput | If true, the absolute value of each input is calculated before comparison to the levels data. |
prog | A sequence program to which the code performing the histogram will be appended. |
debugContext | Optional debug information. |
options | A list of options to control the operation of the histogram function. |
useFloatArithmetic
is "true" the returned tensor will have type float. poplar::invalid_option | If options useFloatArithmetic and useFloatArithmeticWithUnsignedIntOutput are both true. |
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.
graph | The Poplar graph. |
input | The input tensor on which to gather histogram statistics. |
output | The output tensor which will store the histogram results. |
updateOutput | If true, the histogram counts will be added to the values already in output . |
levels | The levels defining the comparisons to carry out in generating the histogram output. |
absoluteOfInput | If true, the absolute value of each input is calculated before comparison to the levels data. |
prog | A sequence program to which the code performing the histogram will be appended. |
debugContext | Optional debug information. |
options | A list of options to control the operation of the histogram function. |
poputil::poplibs_error | If option useFloatArithmeticWithUnsignedIntOutput is true and output does not have UNSIGNED_INT type. |
poplar::invalid_option | If option useFloatArithmetic is true. |
|
inline |
Compute the inverse of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
1 / a
, where a
is an element of A
.
|
inline |
Convert the inverse standard deviation to variance.
graph | The graph to update. |
A | The source tensor. |
B | The destination tensor. |
prog | The sequence to extend with the execution of conversion. |
debugContext | Optional debug information. |
options | A list of flags to pass to the expression evaluator. |
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. 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.
graph | The graph to update. |
src | The source tensor. |
epsilon | A 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. |
prog | The sequence to extend with the execution of conversion. |
dstType | The type of the tensor to be output. Must be FLOAT or equal to the input type. |
debugContext | Optional debug information |
b = (1 / a) ^ 2
, where a
and b
are the corresponding elements of src
and the result tensor respectively. 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.
graph | The graph to add the tensor and any vertices needed for the operation. |
t | 1-D tensor to write the encoded output to. The tensor must be mapped. |
startInteger | The start value in the output range. |
prog | Sequence which the programs that perform the encoding are added to. |
debugContext | Optional debug information. |
poputil::poplibs_error | If the rank of t is greater than 1. |
poputil::poplibs_error | If the type of t is not INT. |
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.
graph | The graph to add the tensor and any vertices needed for the operation. |
t | 1-D tensor to write the encoded output to. The tensor must be mapped. |
startInteger | The start value in the output range. |
prog | Sequence which the programs that perform the encoding are added to. |
debugContext | Optional debug information. |
poputil::poplibs_error | If the rank of t is greater than 1. |
poputil::poplibs_error | If the type of t is not UNSIGNED_INT. |
|
inline |
Check if each element in A
is finite.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::isfinite(a)
, where a
is an element of A
.
|
inline |
Compute the log base-e of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::log(a)
, where a
is an element of A
.
|
inline |
Compute the log base-e of each element in A
plus one.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::log1p(a)
, where a
is an element of A
.
|
inline |
Compute the logical AND (&&
) of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a && b
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the logical NOT of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
!a
, where a
is an element of A
.
|
inline |
Compute the logical OR (||
) of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a || b
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Check if each element in A
is less than the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a < b
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Check if each element in A
is less than or equal to the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a <= b
, where a
and b
are the corresponding elements of A
and B
tensors respectively. 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.
graph | The graph to update. |
expr | The expression to map across the tensors. The placeholders in the expressions will be substituted with corresponding elements from the tensors in ts . |
ts | The 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()). |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | A list of flags to pass to the expression evaluator. |
|
inline |
Compute the maximum of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
max(a, b)
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the minimum of each element in A
with the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
min(a, b)
, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Multiply each element in A
by the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a * b
, where a
and b
are the corresponding elements of A
and B
tensors respectively. 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.
graph | The Poplar graph. |
t | The tensor being sliced. |
offsets | The offsets within t to be sliced. |
dims | The dimensions of t to be sliced. |
sizes | The size of the update in each of the dimensions in dims . |
prog | The program to be extended. |
plan | Plan describing how the operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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
.
graph | The Poplar graph. |
t | The tensor being sliced. |
offsets | The offsets within t to be sliced. |
dims | The dimension of t to be sliced. |
prog | The program to be extended. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
t | The tensor being updated. |
s | The slices to insert. |
offsets | The offsets within t to be updated. |
dims | The dimensions of t to be updated. |
sizes | The size of the update in each of the dimensions in dims . |
prog | The program to be extended. |
plan | Plan describing how the operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
t | The tensor being updated (must be rank 2). |
s | The slices to accumulate. |
offsets | The offsets within t to be accumulated. |
scale | The 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. |
dims | The dimensions of t to be accumulated (must be rank 1). |
sizes | The size of the accumulate in each of the dimensions in dims . |
prog | The program to be extended. |
plan | Plan describing how the operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
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
graph | The Poplar graph. |
t | The tensor being updated. |
s | The slices to accumulate. |
offsets | The offsets within t to be accumulated. |
scale | The 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. |
dim | The dimension of t to be accumulated. |
prog | The program to be extended. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
t | The tensor being updated (must be rank 2). |
s | The slices to find maximum over. |
offsets | The offsets within t to find maximum over. |
dims | The dimensions of t to find maximum over (must be rank 1). |
sizes | The size of the update in each of the dimensions in dims . |
prog | The program to be extended. |
plan | Plan describing how the operation will be implemented. |
options | Flags controlling how the operation will be implemented. |
debugContext | Optional debug information. |
|
inline |
Compute the negation of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
-1 * a
, where a
is an element of A
.
|
inline |
Check if each element in A
is not equal to the corresponding element in B
.
graph | The graph to update. |
A | A tensor of elements. |
B | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a != b
, where a
and b
are the corresponding elements of A
and B
tensors respectively. 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.
graph | The graph containing the tensor. |
seq | The sequence to which the normalisation programs will be added. |
tIn | Input image. It must have an inner dimension of 3. and be UNSIGNED_CHAR , HALF or FLOAT . |
inScale | Input scaling. |
offsets | Offset for each channel. Must be shape {3} and must match the output type. |
scales | Scaling factor for each channel. Must be shape {3} and must match the output type. |
debugContext | Debugging context. |
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".
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".
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
.
target | The target the graph is being constructed to work with. |
expr | The expression to map across the tensors. The placeholders in the expressions will be substituted with corresponding elements from the tensors in ts . |
ts | The 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()). |
options | A list of flags to pass to the expression evaluator. See map() function for details. |
os | The stream to output generated codelet. |
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.
t | The tensor to pad. |
paddingLower | A vector specifying the amount of padding to add at the start of each dimension. Negative padding truncates. |
paddingUpper | A vector specifying the amount of padding to add at the end of each dimension. Negative padding truncates. |
type | The type of padding. |
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.
t | The tensor to pad. |
paddingLower | The amount of padding to add at the start of the dimension. Negative padding truncates. |
paddingUpper | The amount of padding to add at the end of the dimension. Negative padding truncates. |
dim | The dimension to pad. |
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.
graph | The graph containing the tensor. |
t | The tensor to pad. |
paddingLower | A vector specifying the amount of padding to add at the start of each dimension. Negative padding truncates. |
paddingUpper | A vector specifying the amount of padding to add at the end of each dimension. Negative padding truncates. |
val | The input tensor will be padded with this value. |
mappingMethod | The method that should be used to map added padding elements. |
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.
t | The tensor to pad. |
paddingLower | The amount of padding to add at the start of the dimension. Negative padding truncates. |
paddingUpper | The amount of padding to add at the end of the dimension. Negative padding truncates. |
dim | The dimension to pad. |
val | The input tensor will be padded with this value. |
mappingMethod | The method that should be used to map added padding elements. |
|
inline |
Compute the number of 1 bits in each element of A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::popcount(a)
, where a
is an element of A
.
|
inline |
Compute each element in A
to the power of the corresponding element in B
.
graph | The graph to update. |
A | The tensor of bases. |
B | The tensor of exponents. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
pow(a, b)
, where a
and b
are the corresponding elements of A
and B
tensors respectively. 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->floatLOG_ADD
: float->float, half->half, float->half, half->floatMAX
, MIN
: float->float, half->half, int->intLOGICAL_AND
, LOGICAL_OR
: bool->boolgraph | The graph to add the operation to. |
in | The tensor to be reduced. |
outType | The output type of the reduce operation. |
dims | The dimensions to reduce in. |
prog | The program sequence to add the operation to. |
debugContext | Optional debug information. |
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.
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->floatLOG_ADD
: float->float, half->half, float->half, half->floatMAX
, MIN
: float->float, half->half, int->intLOGICAL_AND
, LOGICAL_OR
: bool->boolgraph | The graph to add the operation to. |
in | The tensor to be reduced. |
outType | The output type of the reduce operation. |
dims | The dimensions to reduce in. |
prog | The program sequence to add the operation to. |
debugContext | Optional debug information. |
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->floatLOG_ADD
: float->float, half->half, float->half, half->floatMAX
, MIN
: float->float, half->half, int->intLOGICAL_AND
, LOGICAL_OR
: bool->boolgraph | The graph to add the operation to. |
in | The tensor to be reduced. |
outType | The output type of the reduce operation. |
dims | The dimensions to reduce in. |
prog | The program sequence to add the operation to. |
debugContext | Optional debug information. |
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.
reductions | The 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. |
outputs | The 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. |
poputils::poplibs_error | If outputs is not empty then its size must exactly match the size of reductions else an exception will be thrown. |
poputils::poplibs_error | If 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. |
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->floatLOG_ADD
: float->float, half->half, float->half, half->floatMAX
, MIN
: float->float, half->half, int->intLOGICAL_AND
, LOGICAL_OR
: bool->boolgraph | The graph to add the operation to. |
in | The tensor to be reduced. |
outType | The output type of the reduce operation. |
dims | The dimensions to reduce in. |
prog | The program sequence to add the operation to. |
debugContext | Optional debug information. |
|
inline |
Compute the remainder of each element in A
divided by the corresponding element in B
.
graph | The graph to update. |
A | The tensor of dividends. |
B | The tensor of divisors. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Round each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::round(a)
, where a
is an element of A
.
|
inline |
Compute the reciprocal square root for each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
1 / sqrt(a)
, where a
is an element of A
. 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.
graph | The Poplar graph. |
A | The destination tensor. |
scaleA | The constant to multiply elements of A with before addition. |
B | The second tensor to add elements from (must be of the same shape as A ). |
scaleB | The constant to multiply elements of B with before addition. |
prog | A sequence program to which the code performing the add will be appended. |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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.
graph | The Poplar graph. |
A | The destination tensor. |
scaleA | The constant to multiply elements of A with before addition. |
B | The second tensor to add elements from (must be of the same shape as A ). |
scaleB | The constant to multiply elements of B with before addition. |
prog | A sequence program to which the code performing the add will be appended. |
speciality | Choice of ScaledAdd expression formulation |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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
.
graph | The Poplar graph. |
A | The destination tensor. |
B | The second tensor to add elements from (must be of the same shape as A ). |
scaleB | The scalar to multiply elements of B with before addition. |
prog | A sequence program to which the code performing the add will be appended. |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. |
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
.
graph | The Poplar graph. |
A | The destination tensor. |
B | The second tensor to add elements from (must be of the same shape as A ). |
scaleB | The scalar tensor to multiply elements of B with before addition. |
prog | A sequence program to which the code performing the add will be appended. |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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
.
graph | The Poplar graph. |
A | The destination tensor. |
scaleA | The scalar tensor to multiply elements of A with before addition. |
B | The second tensor to add elements from (must be of the same shape as A ). |
scaleB | The scalar tensor to multiply elements of B with before addition. |
prog | A sequence program to which the code performing the add will be appended. |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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
.
graph | The Poplar graph. |
A | The destination tensor. |
scaleA | The scalar tensor to multiply elements of A with before addition. |
B | The second tensor to add elements from (must be of the same shape as A ). |
scaleB | The scalar tensor to multiply elements of B with before addition. |
prog | A sequence program to which the code performing the add will be appended. |
speciality | Choice of ScaledAdd expression formulation |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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.
graph | The Poplar graph. |
A | The destination tensor. |
scaleA | The constant to multiply elements of A with before subtraction. |
B | The second tensor to subtract elements from (must be of the same shape as A ). |
scaleB | The constant to multiply elements of B with before subtraction. |
prog | A sequence program to which the code performing the subtract will be appended. |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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
.
graph | The Poplar graph. |
A | The destination tensor. |
B | The second tensor providing the elements to subtract (must be of the same shape as A ). |
scaleB | The scalar to multiply elements of B with before subtraction. |
prog | A sequence program to which the code performing the add will be appended. |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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
.
graph | The Poplar graph. |
A | The destination tensor. |
B | The second tensor providing the elements to subtract (must be of the same shape as A ). |
scaleB | The scalar tensor to multiply elements of B with before subtraction. |
prog | A sequence program to which the code performing the add will be appended. |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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
.
graph | The Poplar graph. |
A | The destination tensor. |
scaleA | The scalar tensor to multiply elements of A with before subtraction. |
B | The second tensor to subtract elements from (must be of the same shape as A ). |
scaleB | The scalar tensor to multiply elements of B with before subtraction. |
prog | A sequence program to which the code performing the subtract will be appended. |
debugContext | Optional debug information. |
options | A list of flags to control optimizations. See scaledAddTo(). |
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
.
graph | The Poplar graph. |
operand | Array to be scattered into. |
indices | Array containing the starting indices of the slices that must be scattered to. |
updates | Array containing the values that must be used for scattering. |
indexVectorDim | The dimension in indices that contains the starting indices. |
updateWindowDims | The set of dimensions in updates shape that are window dimensions. |
insertWindowDims | The set of window dimensions that must be inserted into updates shape. |
scatterDimsToOperandDims | A 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. |
prog | The program to be extended. |
debugContext | Optional debug information. |
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.
graph | The Poplar graph. |
operand | Array to be scattered into. |
indices | Array containing the starting indices of the slices that must be scattered to. |
updates | Array containing the values that must be used for scattering. |
indexVectorDim | The dimension in indices that contains the starting indices. |
updateWindowDims | The set of dimensions in updates shape that are window dimensions. |
insertWindowDims | The set of window dimensions that must be inserted into updates shape. |
scatterDimsToOperandDims | A 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. |
updateComputation | Computation to be used for combining the existing values in the input tensor and the updates during scatter. |
prog | The program to be extended. |
debugContext | Optional debug information. |
|
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.
graph | The graph to update. |
A | One of the tensors containing the elements to select from. |
B | One of the tensors containing the elements to select from. |
C | The tensor containing the elements to use as predicates. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
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. 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.
graph | The Poplar graph. |
params | A 2D tensor, the element type must be either float or half. |
indices | A 1D tensor, the element type must be unsigned integer. |
prog | The program to be extended. |
debugContext | Optional 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.
params[indices[i]]
. 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.
graph | The Poplar graph. |
tIn | The source tensor. |
tOut | The destination tensor. |
tN | The number of elements to copy. |
tInOffset | First element read from tIn . |
tOutOffset | First element written in tOut . |
zeroUnused | Whether to zero unreferenced tOut elements. |
prog | The program to be extended. |
debugContext | Optional debug information. |
|
inline |
Shift the elements of A
left by the corresponding elements of B
.
graph | The graph to update. |
A | The tensor of elements which to left-shift. |
B | The tensor of elements that describe the amount to left-shift A by. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Shift the elements of A
right by the corresponding elements of B
.
graph | The graph to update. |
A | The tensor of elements which to right-shift. |
B | The tensor of elements that describe the amount to right-shift by. A . |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Shift the elements of A
right with sign extension by the corresponding elements of B
.
graph | The graph to update. |
A | The tensor of elements which to right-shift. |
B | The tensor of elements that describe the amount to right-shift A by. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a >> b
with sign extension, where a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the sigmoid (logistic) function for each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
1 / (1 + exp(-x))
, where a
is an element of A
.
|
inline |
Compute the signum of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
A
was less than, equal to or greater than 0 respectively.
|
inline |
Compute the sine of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::sin(a)
, where a
is an element of A
. poplar::Tensor popops::sort | ( | poplar::Graph & | graph, |
const poplar::Tensor & | t, | ||
unsigned | dim, | ||
poplar::program::Sequence & | prog, | ||
const poplar::DebugContext & | debugContext = {} |
||
) |
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
graph | The Poplar graph. |
t | The source tensor. |
dim | The dimension to sort on. |
prog | The program to be extended. |
debugContext | Optional debug information. |
t
such that all elements in the given dimension are in order.poputil::poplibs_error | If dim is not a valid dimension of v . |
void popops::sortInPlace | ( | poplar::Graph & | graph, |
const poplar::Tensor & | t, | ||
unsigned | dim, | ||
poplar::program::Sequence & | prog, | ||
const poplar::DebugContext & | debugContext = {} |
||
) |
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.
graph | The Poplar graph. |
t | The source tensor to be sorted. |
dim | The dimension to sort on. |
prog | The program to be extended. |
debugContext | Optional debug information. |
poputil::poplibs_error | If dim is not a valid dimension of v . |
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 = {} |
||
) |
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
graph | The Poplar graph. |
k | The key tensor to sort on. |
v | The value tensor to be sorted. |
dim | The dimension to sort on. |
prog | The program to be extended. |
debugContext | Optional debug information. |
v
such that it is in order with respect to the tensor k
in the given dimension.k
and v
alias, the result is undefined.poputil::poplibs_error | If dim is not a valid dimension of v . |
poputil::poplibs_error | If v and k are not the same shape. |
void popops::sortKeyValueInPlace | ( | poplar::Graph & | graph, |
const poplar::Tensor & | k, | ||
const poplar::Tensor & | v, | ||
unsigned | dim, | ||
poplar::program::Sequence & | prog, | ||
const poplar::DebugContext & | debugContext = {} |
||
) |
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.
graph | The Poplar graph. |
k | The key tensor to sort on. |
v | The value tensor to be sorted. |
dim | The dimension to sort on. |
prog | The program to be extended. |
debugContext | Optional debug information. |
k
tensor is also sorted by this in-place operation. k
tensor and the v
tensor alias, the result is undefined.poputil::poplibs_error | If dim is not a valid dimension of v . |
poputil::poplibs_error | If v and k are not the same shape. |
|
inline |
Compute the square-root for each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::sqrt(a)
, where a
is an element of A
.
|
inline |
Compute the square for each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
x * x
, where a
is an element of A
.
|
inline |
Subtract the elements of B
from A
and return the result in a new tensor.
graph | The graph to update. |
A | The tensor of elements which will be subtracted from. |
B | The tensor of elements to subtract from A . |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information. |
options | Element-wise options. See map(). |
a
and b
are the corresponding elements of A
and B
tensors respectively.
|
inline |
Compute the tangent of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::tan(a)
, where a
is an element of A
.
|
inline |
Compute the hyperbolic tangent of each element in A
.
graph | The graph to update. |
A | A tensor of elements. |
prog | The sequence to extend with the execution of the expression evaluation. |
debugContext | Optional debug information |
options | Element-wise options. See map(). |
std::tanh(a)
, where a
is an element of A
. 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.
graph | The Poplar graph to add the operation to. |
prog | The Poplar sequence to add the operation to. |
t | The tensor in which to find the top-k values in the innermost dimension. |
params | The parameters of the top k. |
debugContext | Optional debug information. |
t
. 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.
graph | The Poplar graph to add the operation to. |
prog | The Poplar sequence to add the operation to. |
key | The tensor in which to find the top-k values in the innermost dimension. |
value | A tensor with the same shape as key for which to get the permutation with respect to key . |
params | The parameters of the top k. |
debugContext | Optional debug information. |
key
. The second contains the permutation of the tensor value
with respect to the tensor key
. 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.
graph | The Poplar graph to add the operation to. |
prog | The Poplar sequence to add the operation to. |
t | The tensor in which to find the top-k values in the innermost dimension. |
params | The parameters of the top k. |
debugContext | Optional debug information. |
t
. The second contains the indices of those values in the innermost dimension of t
in the original input. 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:
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
graph | The Poplar graph. |
params | The 2D tensor to be updated, the element type must be either float or half. |
indices | 1D tensor, the element-type must be unsigned integer. |
program | The program to be extended. |
debugContext | Optional debug information. |
|
inline |
Convert variance to inverse standard deviation.
graph | The graph to update. |
A | The source tensor. |
B | The destination tensor. |
prog | The sequence to extend with the execution of conversion. |
debugContext | Optional debug information. |
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. 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.
graph | The graph to update. |
src | The source tensor. |
epsilon | A 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. |
prog | The sequence to extend with the execution of conversion. |
dstType | The type of the tensor to be output. Must be HALF or equal to the input type. |
debugContext | Optional debug information |
b = sqrt(1 / a)
, where a
and b
are the corresponding elements of src
and the result tensor respectively. 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
.
graph | The graph that the operation will be added to. |
t | The tensor whose elements are to be set to zero. |
mapping | The 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 . |
zeroCS | The compute set to add the operation to. |
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
.
graph | The graph that the operation will be added to. |
t | The tensor whose elements are to be set to zero. |
prog | The Poplar program sequence to append the operation to. |
debugContext | Optional debug information. |
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
.
graph | The graph that the operation will be added to. |
t | The tensor whose elements are to be set to zero. |
tile | The tile which the tensor is mapped to. |
zeroCS | The compute set to add the operation to. |
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
.
graph | The graph that the operation will be added to. |
t | The tensor whose elements are to be set to zero. |
tileRegions | The region mapping of the tensor on tile . |
tile | The tile which the regions relate to. |
zeroCS | The compute set to add the operation to. |