Rearrange

#include <popops/Rearrange.hpp>

Operations to rearrange tensors on tiles.

Deprecated:

This file is deprecated.

namespace popops

Common functions, such as elementwise and reductions.

map

Map an expression across tensors.

Elementwise Options

  • enableGenerateCodelet (true, false) [=true]

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

    • All of the inputs are of the same size

    • Inputs do not alias

    • Multiple operations are being performed

mapInPlace

Update the input tensors with the result of map().

mapWithOutput

Write the result of map() to the given output tensor.

checkTypes

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

param elementType

The run-time IPU type.

param constant

Unused.

tparam constType

The host compile-time type.

throws std::runtime_error

If the types are not compatible.

varianceToInvStdDev

Convert variance to inverse standard deviation.

Each element in the output tensor is the result of 1 / sqrt(variance_value + epsilon), where variance_value is the corresponding element in variance.

Warning

If variance_value + epsilon is zero then the result will be invalid and this operation could generate a divide-by-zero floating-point exception (if enabled).

param graph

The graph to update.

param variance

A tensor of variance values.

param epsilon

A (typically small) scalar to add to the variance values, to avoid numerical issues (for example, divide by zero).

param prog

The sequence of programs to append this conversion operation to.

param debugContext

Optional debug information.

return

A tensor where each element is the inverse standard deviation.

invStdDevToVariance

Convert inverse standard deviation to variance.

Each element in the output tensor is the result of 1 / (invStdDev_value + epsilon)^2, where invStdDev_value is the corresponding element in invStdDev.

Warning

If invStdDev_value + epsilon is zero then the result will be invalid and this operation could generate a divide-by-zero floating-point exception (if enabled).

param graph

The graph to update.

param invStdDev

A tensor of inverse standard deviation values.

param epsilon

A (typically small) scalar to add to the variance values, to avoid numerical issues (for example, divide by zero).

param prog

The sequence of programs to append this conversion operation to.

param debugContext

Optional debug information.

param options

A list of flags to pass to the expression evaluator.

return

A tensor where each element is the variance.

add

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of a + b, where a and b are the corresponding elements of A and B tensors respectively.

addInPlace

Update the tensor A with the result of add().

See add() for parameter descriptions.

addWithOutput

Write the result of add() to the given output tensor, out.

See add() for the remaining parameter descriptions.

param out

The tensor to write the results to.

sub

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

param graph

The graph to update.

param A

The tensor of elements which will be subtracted from.

param B

The tensor of elements to subtract from A.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is equal to a - b, where a and b are the corresponding elements of A and B tensors respectively.

subInPlace

Update the tensor A with the result of sub().

See sub() for parameter descriptions.

subWithOutput

Write the result of sub() to the given output tensor, out.

See sub() for the remaining parameter descriptions.

param out

The tensor to write the results to.

mul

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is the result of a * b, where a and b are the corresponding elements of A and B tensors respectively.

mulInPlace

Update the tensor A with the result of mul().

See mul() for parameter descriptions.

mulWithOutput

Write the result of mul() to the given output tensor, out.

See mul() for the remaining parameter descriptions.

param out

The tensor to write the results to.

div

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

param graph

The graph to update.

param A

The tensor of dividends.

param B

The tensor of divisors.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of a / b, where a and b are the corresponding elements of A and B tensors respectively.

divInPlace

Update the tensor A with the result of div().

See div() for parameter descriptions.

divWithOutput

Write the result of div() to the given output tensor, out.

See div() for the remaining parameter descriptions.

param out

The tensor to write the results to.

pow

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

param graph

The graph to update.

param A

The tensor of bases.

param B

The tensor of exponents.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is equal to pow(a, b), where a and b are the corresponding elements of A and B tensors respectively.

powInPlace

Update the tensor A with the result of pow().

See pow() for parameter descriptions.

powWithOutput

Write the result of pow() to the given output tensor, out.

See pow() for the remaining parameter descriptions.

param out

The tensor to write the results to.

rem

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

param graph

The graph to update.

param A

The tensor of dividends.

param B

The tensor of divisors.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is equal to a % b, where a and b are the corresponding elements of A and B tensors respectively.

remInPlace

Update the tensor A with the result of rem().

See rem() for parameter descriptions.

remWithOutput

Write the result of rem() to the given output tensor, out.

See rem() for the remaining parameter descriptions.

param out

The tensor to write the results to.

bitwiseAnd

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of a & b, where a and bare the corresponding elements of A and B tensors respectively.

bitwiseAndInPlace

Update the tensor A with the result of bitwiseAnd().

See bitwiseAnd() for parameter descriptions.

bitwiseAndWithOutput

Write the result of bitwiseAnd() to the given output tensor, out.

See bitwiseAnd() for the remaining parameter descriptions.

param out

The tensor to write the results to.

bitwiseOr

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of a | b, where a and b are the corresponding elements of A and B tensors respectively.

bitwiseOrInPlace

Update the tensor A with the result of bitwiseOr().

See bitwiseOr() for parameter descriptions.

bitwiseOrWithOutput

Write the result of bitwiseOr() to the given output tensor, out.

See bitwiseOr() for the remaining parameter descriptions.

param out

The tensor to write the results to.

bitwiseXor

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of a ^ b, where a and b are the corresponding elements of A and B tensors respectively.

bitwiseXorInPlace

Update the tensor A with the result of bitwiseXor().

See bitwiseXnor() for parameter descriptions.

bitwiseXorWithOutput

Write the result of bitwiseXor() to the given output tensor, out.

See bitwiseXor() for the remaining parameter descriptions.

param out

The tensor to write the results to.

bitwiseXnor

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of !(a ^ b), where a and b are the corresponding elements of A and B tensors respectively.

bitwiseXnorInPlace

Update the tensor A with the result of bitwiseXnor().

See bitwiseXnor() for parameter descriptions.

bitwiseXnorWithOutput

Write the result of bitwiseXnor() to the given output tensor, out.

See bitwiseXnor() for the remaining parameter descriptions.

param out

The tensor to write the results to.

shiftLeft

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

param graph

The graph to update.

param A

The tensor of elements which to left-shift.

param B

The tensor of elements that describe the amount to left-shift A by.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is equal to a << b, where a and b are the corresponding elements of A and B tensors respectively.

shiftLeftInPlace

Update the tensor A with the result of shiftLeft().

See shiftLeft() for parameter descriptions.

shiftLeftWithOutput

Write the result of shiftLeft() to the given output tensor, out.

See shiftLeft() for the remaining parameter descriptions.

param out

The tensor to write the results to.

shiftRight

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

param graph

The graph to update.

param A

The tensor of elements which to right-shift.

param B

The tensor of elements that describe the amount to right-shift by. A.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is equal to a >> b (without sign extension), where a and b are the corresponding elements of A and B tensors respectively.

shiftRightInPlace

Update the tensor A with the result of shiftRight().

See shiftRight() for parameter descriptions.

shiftRightWithOutput

Write the result of shiftRight() to the given output tensor, out.

See shiftRight() for the remaining parameter descriptions.

param out

The tensor to write the results to.

shiftRightSignExtend

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

param graph

The graph to update.

param A

The tensor of elements which to right-shift.

param B

The tensor of elements that describe the amount to right-shift A by.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is equal to a >> b with sign extension, where a and b are the corresponding elements of A and B tensors respectively.

shiftRightSignExtendInPlace

Update the tensor A with the result of shiftRightSignExtend().

See shiftRightSignExtend() for parameter descriptions.

shiftRightSignExtendWithOutput

Write the result of shiftRightSignExtend() to the given output tensor, out.

See shiftRightSignExtend() for the remaining parameter descriptions.

param out

The tensor to write the results to.

logicalAnd

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is the result of a && b, where a and b are the corresponding elements of A and B tensors respectively.

logicalAndInPlace

Update the tensor A with the result of logicalAnd().

See logicalAnd() for parameter descriptions.

logicalAndWithOutput

Write the result of logicalAnd() to the given output tensor, out.

See logicalAnd() for the remaining parameter descriptions.

param out

The tensor to write the booleans to.

logicalOr

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is the result of a || b, where a and b are the corresponding elements of A and B tensors respectively.

logicalOrInPlace

Update the tensor A with the result of logicalOr().

See logicalOr() for parameter descriptions.

logicalOrWithOutput

Write the result of logicalOr() to the given output tensor, out.

See logicalOr() for the remaining parameter descriptions.

param out

The tensor to write the booleans to.

eq

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of a == b, where a and b are the corresponding elements of A and B tensors respectively.

eqInPlace

Update the tensor A with the result of eq().

See eq() for parameter descriptions.

eqWithOutput

Write the result of eq() to the given output tensor, out.

See eq() for the remaining parameter descriptions.

param out

The tensor to write the booleans to.

neq

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is the result of a != b, where a and b are the corresponding elements of A and B tensors respectively.

neqInPlace

Update the tensor A with the result of neq().

See neq() for parameter descriptions.

neqWithOutput

Write the result of neq() to the given output tensor, out.

See neq() for the remaining parameter descriptions.

param out

The tensor to write the booleans to.

gteq

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of a >= b, where a and b are the corresponding elements of A and B tensors respectively.

gteqInPlace

Update the tensor A with the result of gteq().

See gteq() for parameter descriptions.

gteqWithOutput

Write the result of gteq() to the given output tensor, out.

See gteq() for the remaining parameter descriptions.

param out

The tensor to write the booleans to.

gt

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of a > b, where a and b are the corresponding elements of A and B tensors respectively.

gtInPlace

Update the tensor A with the result of gt().

See gt() for parameter descriptions.

gtWithOutput

Write the result of gt() to the given output tensor, out.

See gt() for the remaining parameter descriptions.

param out

The tensor to write the booleans to.

lteq

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is the result of a <= b, where a and b are the corresponding elements of A and B tensors respectively.

lteqInPlace

Update the A with the result of lteq().

See lteq() for parameter descriptions.

lteqWithOutput

Write the result of lteq() to the given output tensor, out.

See lteq() for the remaining parameter descriptions.

param out

The tensor to write the booleans to.

lt

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is the result of a < b, where a and b are the corresponding elements of A and B tensors respectively.

ltInPlace

Update the A with the result of lt().

See lt() for parameter descriptions.

ltWithOutput

Write the result of lt() to the given output tensor, out.

See lt() for the remaining parameter descriptions.

param out

The tensor to write the boolean results to.

max

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is the result of max(a, b), where a and b are the corresponding elements of A and B tensors respectively.

maxInPlace

Update the tensor A with the result of max().

See max() for parameter descriptions.

maxWithOutput

Write the result of max() to the given output tensor, out.

See max() for the remaining parameter descriptions.

param out

The tensor to write the maximums to.

min

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

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information.

param options

Element-wise options. See map().

return

A tensor where each element is the result of min(a, b), where a and b are the corresponding elements of A and B tensors respectively.

minInPlace

Update the tensor A with the result of min().

See min() for parameter descriptions.

minWithOutput

Write the result of min() to the given output tensor, out.

See min() for the remaining parameter descriptions.

param out

The tensor to write the minimums to.

atan2

Compute the element-wise arctangent of A / B.

param graph

The graph to update.

param A

A tensor of elements.

param B

A tensor of elements.

param prog

The sequence to extend with the execution of the expression evaluation.

param debugContext

Optional debug information

param options

Element-wise options. See map().

return

A tensor where each element is the result of arctan(a / b); a and b are the corresponding elements of A and B tensors respectively.

atan2InPlace

Update the tensor A with the result of atan2().

See atan2() for parameter descriptions.

atan2WithOutput

Write the result of atan2() to the given output tensor, out.

See atan2() for the remaining parameter descriptions.

param out

The tensor to write the result to.

invStdDevToVarianceInPlace

Update the invStdDev tensor with the result of invStdDevToVariance().

See invStdDevToVariance() for parameter descriptions.

invStdDevToVarianceWithOutput

Write the result of invStdDevToVariance() to the given output tensor, out.

See invStdDevToVariance() for the remaining parameter descriptions.

param out

The tensor to write the variance to.

varianceToInvStdDevInPlace

Update the variance tensor with the result of varianceToInvStdDev().

See varianceToInvStdDev() for parameter descriptions.

varianceToInvStdDevWithOutput

Write the result of varianceToInvStdDev() to the given output tensor, out.

See varianceToInvStdDev() for the remaining parameter descriptions.

param out

The tensor to write inverse standard deviation to.

namespace rearrange

Functions

bool canUseFastTranspose(const poplar::Target &target, const poplar::Type &type, unsigned numRows, unsigned numColumns, unsigned numTranspositions)

Determine if a fast transposition codelet may be used based on the given target/data type/no.

of rows/no. of columns.

Deprecated:

This function is deprecated

Parameters
  • target – The target the operation will be targeted at.

  • type – The data type of the tensor to transpose.

  • numRows – The no. of rows in each transposition to perform.

  • numColumns – The no. of columns in each transposition to perform.

Returns

A boolean indicating whether or not the fast transposition codelets can be targeted based on the given parameters.

void addTransposeVertices(poplar::Graph &graph, const poplar::ComputeSet &cs, const poplar::Type &dType, unsigned rows, unsigned cols, const poplar::Graph::TileToTensorMapping &mapping, std::function<std::pair<const poplar::Tensor, const poplar::Tensor>(size_t)> getInOut, const poplar::DebugContext &debugContext = {})

Transposes of a set of matrices stored on multiple tiles.

This adds all the needed vertices on the graph.

Deprecated:

This function is deprecated

Parameters
  • graph, cs – The graph and compute set to add the vertices to.

  • dType, rows, cols – The type and dimensions of the matrices to be transposed, the same for all of them.

  • mapping – A vector with ‘number of tiles’ elements, where each element is a vector of intervals indicating which matrices to be transposed are mapped (possibly partially) on each tile.

  • getInOut – A function: pair<Tensor, Tensor> getInOut(size_t index), which, given as input an index inside the intervals specified in ‘mapping’, returns a std::pair of Tensors (in, out) which are the input and output matrix for the ‘index’ transposition. The ‘in’ and ‘out’ return values are 2D matrices, but they must be flattened to a single dimension.

poplar::Tensor partialTranspose(poplar::Graph &graph, const poplar::Tensor &in, const poplar::ComputeSet &cs, const poplar::DebugContext &debugContext = {})

Transpose the innermost pair of dimensions of the specified tensor, writing the results to a new tensor.

This function assumes order of the underlying storage matches the order of the elements in the tensor. This function is optimized for group sizes that are typical of the underlying memory layout of convolution activations / weights - it may be inefficient for other group sizes.

Deprecated:

This function is deprecated

unsigned getMinimumRegroupGrainSize(const poplar::Type &type)

Get the smallest grouping we can transpose between for the given type using fast transposition codelets.

Deprecated:

This function is deprecated

Parameters

type – The data type to be transposed.

Returns

The smallest size of grouping that can be efficiently transposed for the given type.

poplar::Tensor regroupTensor(poplar::Graph &graph, const poplar::Tensor &t, poplar::program::Sequence &copies, const poplar::ComputeSet &transposeCS, const poputil::GroupingInfo &from, const poputil::GroupingInfo &to, const poplar::DebugContext &debugContext = {})

Insert copies or other operations into the given programs/compute sets to transform the grouping found on the given tensor from from to to.

This is a no-op for a one-dimensional tensor.

Deprecated:

This function is deprecated

Parameters
  • graph – The graph to add the operation to.

  • t – The tensor to regroup.

  • copies – A poplar sequence to add pre-arranging copies to.

  • transposeCS – A compute set that may or may not have vertices added to it to perform the regrouping operation.

  • from – A grouping that is applied to the given tensor t to rearrange from.

  • to – A grouping wanted on the returned tensor.

  • debugContext – Optional debug information.

Returns

A tensor with the contents of t but laid out such that it has the grouping specified in to.

poplar::Tensor regroupIfPossible(poplar::Graph &graph, const poplar::Tensor &t, poplar::program::Sequence &prog, const poputil::GroupingInfo &to, const poplar::DebugContext &debugContext = {})

Insert copies or other operations into the given program to transform the grouping found on the given tensor to to.

This is a no-op for a one-dimensional tensor and if regrouping is not possible. Regrouping may not be possible or done if grouping exists only on the requested dimension, or no suitable grain size is available for efficient regrouping.

Deprecated:

This function is deprecated

Parameters
  • graph – The graph to add the operation to.

  • t – The tensor to regroup.

  • prog – A poplar sequence to add any pre-arranging and other operations to.

  • to – A grouping wanted on the returned tensor.

  • debugContext – Optional debug information.

Returns

A tensor with the contents of t but laid out such that it has the grouping specified in to.

poplar::Tensor regroupTensor(poplar::Graph &graph, const poplar::Tensor &t, std::vector<poplar::program::Copy> &copies, const poplar::ComputeSet &transposeCS, const poputil::GroupingInfo &from, const poputil::GroupingInfo &to, const poplar::DebugContext &debugContext = {})

Insert copies or other operations into the given programs/compute sets to transform the grouping found on the given tensor from from to to.

This is a no-op for a one-dimensional tensor.

Overload that takes a vector of Copy programs instead of a Sequence.

Deprecated:

This function is deprecated

Parameters
  • graph – The graph to add the operation to.

  • t – The tensor to regroup.

  • copies – A vector to add pre-arranging copies to.

  • transposeCS – A compute set that may or may not have vertices added to it to perform the regrouping operation.

  • from – A grouping that is applied to the given tensor t to rearrange from.

  • to – A grouping wanted on the returned tensor.

  • debugContext – Optional debug information.

Returns

A tensor with the contents of t but laid out such that it has the grouping specified in to.

poplar::Tensor regroupIfBeneficial(poplar::Graph &graph, const poplar::Tensor &in, const poplar::Tensor &ref, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {})

If possible and runtime efficient, add an operation to rearrange the given tensor in memory such that the grouping of the resulting tensor matches that of the reference tensor, or a factor of that grouping if it balances memory usage across the target better.

Deprecated:

This function is deprecated

Parameters
  • graph – The graph to add the operation to.

  • in – The tensor to maybe regroup.

  • ref – A reference tensor which will be introspected to find a grouping to apply to the returned tensor.

  • prog – A poplar sequence to add the regrouping operation to.

  • debugContext – Optional debug information.

Returns

A tensor with the contents of the given tensor in rearranged in memory to have a grouping matching ref.

poplar::Tensor regroupIfBeneficial(poplar::Graph &graph, const poplar::Tensor &in, const poplar::Tensor &ref, std::vector<poplar::program::Copy> &copies, poplar::ComputeSet transposeCS, const poplar::DebugContext &debugContext = {})

If possible and runtime efficient, add an operation to rearrange the given tensor in memory such that the grouping of the resulting tensor matches that of the reference tensor, or a factor of that grouping if it balances memory usage across the target better.

Overload that takes a vector of Copy programs instead of a Sequence.

Deprecated:

This function is deprecated

Parameters
  • graph – The graph to add the operation to.

  • in – The tensor to maybe regroup.

  • ref – A reference tensor which will be introspected to find a grouping to apply to the returned tensor.

  • copies – A vector to add pre-arranging copies to.

  • debugContext – Optional debug information.

Returns

A tensor with the contents of the given tensor in rearranged in memory to have a grouping matching ref.

poplar::Tensor regroupIfBeneficial(poplar::Graph &graph, const poplar::Tensor &in, std::size_t preferredGrouping, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {})

If possible and runtime efficient, add an operation to rearrange the given tensor in memory such that the resulting tensor has a grouping in the innermost dimension equivalent to, or a factor of the given preferred grouping if it balances memory usage across the target better.

Deprecated:

This function is deprecated

Parameters
  • graph – The graph to add the operation to.

  • in – The tensor to maybe regroup.

  • preferredGrouping – A size of grouping of the innermost dimension of the given tensor to regroup to.

  • prog – A poplar sequence to add the regrouping operation to.

  • debugContext – Optional debug information.

Returns

A tensor with the contents of the given tensor in rearranged in memory to have a grouping matching ref.