ElementWise
#include <popops/ElementWise.hpp>
These functions perform the same operation on each element of one or more tensors.
Every function has four ways of providing the output:
Returning a new output tensor.
Writing the output to the first input tensor argument. These functions are suffixed with
InPlace
and are useful when you don’t need the input tensor after the operation as they don’t create a new live variable for the output.Writing the output to an “out” tensor passed as an argument. These functions are suffixed with
WithOutput
and are useful for providing your own tile mapping for the output tensor.Performing multiple expressions in one map call.
The functions that perform operations on two tensors support NumPy-style broadcasting of operands, where tensors of different shapes will be broadcast into compatible shapes for the operation. These functions also have overloads where one of the tensors is a constant scalar, which by taking advantage of the broadcasting, performs the same operation on each element in the remaining tensor using the scalar as the other side of the operation for all elements.
See also
Refer to the tutorial Using PopLibs for a full example of how element-wise operations are used.
-
namespace poputil
General utility functions for building graphs.
Functions
-
template<>
poplar::ProfileValue toProfileValue(const popops::expr::UnaryOpType &op)
-
template<>
poplar::ProfileValue toProfileValue(const popops::expr::BinaryOpType &op)
-
template<>
poplar::ProfileValue toProfileValue(const popops::expr::TernaryOpType &op)
-
template<>
-
namespace popops
Common functions, such as elementwise and reductions.
Unnamed Group
-
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.
Elementwise Options
enableGenerateCodelet
(true, false) [=true]When true and the following conditions are met, poplar will generate a codelet to execute the map operation. Otherwise, it will sequence poplibs codelets to create the expression.
All of the inputs are of the same size
Inputs do not alias
Multiple operations are being performed
- Parameters
graph – The graph to update.
expr – The expression(s) 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.
- Returns
A tensor containing the elements resulting from the application of the expression across the tensors.
-
inline poplar::Tensor map(poplar::Graph &graph, expr::UnaryOpType op, const poplar::Tensor &t, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {}, const poplar::OptionFlags &options = {})
-
inline poplar::Tensor map(poplar::Graph &graph, expr::BinaryOpType op, const poplar::Tensor &a, const poplar::Tensor &b, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {}, const poplar::OptionFlags &options = {})
Unnamed Group
-
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().
-
inline void mapInPlace(poplar::Graph &graph, expr::UnaryOpType op, const poplar::Tensor &t, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {}, const poplar::OptionFlags &options = {})
-
inline void mapInPlace(poplar::Graph &graph, expr::BinaryOpType op, const poplar::Tensor &a, const poplar::Tensor &b, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {}, const poplar::OptionFlags &options = {})
Unnamed Group
-
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.
-
inline void mapWithOutput(poplar::Graph &graph, expr::UnaryOpType op, const poplar::Tensor &in, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {}, const poplar::OptionFlags &options = {})
-
inline void mapWithOutput(poplar::Graph &graph, expr::BinaryOpType op, const poplar::Tensor &a, const poplar::Tensor &b, const poplar::Tensor &out, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {}, const poplar::OptionFlags &options = {})
Unnamed Group
-
template<typename constType>
inline void checkTypes(poplar::Type elementType, constType) Check that the host compile-time type
constType
is compatible with the run-time IPU typeelementType
.- Parameters
elementType – The run-time IPU type.
constant – Unused.
- Template Parameters
constType – The host compile-time type.
- Throws
std::runtime_error – If the types are not compatible.
Unnamed Group
-
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.
- Parameters
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
- Returns
A tensor where each element is the inverse of standard deviation. Each element is the result of
b = sqrt(1 / a)
, wherea
andb
are the corresponding elements ofsrc
and the result tensor respectively.
Unnamed Group
-
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.
- Parameters
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
- Returns
A tensor where each element is the variance. Each element is the result of
b = (1 / a) ^ 2
, wherea
andb
are the corresponding elements ofsrc
and the result tensor respectively.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a + b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of add().See add() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See add() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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
fromA
and return the result in a new tensor.- Parameters
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().
- Returns
A tensor where each element is equal to a - b, where
a
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of sub().See sub() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See sub() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a * b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of mul().See mul() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See mul() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a / b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of div().See div() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See div() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is equal to
pow(a, b)
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of pow().See pow() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See pow() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is equal to a % b, where
a
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of rem().See rem() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See rem() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a & b
, wherea
andbare
the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of bitwiseAnd().See bitwiseAnd() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See bitwiseAnd() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a | b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of bitwiseOr().See bitwiseOr() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See bitwiseOr() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a ^ b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of bitwiseXor().See bitwiseXnor() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See bitwiseXor() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
!(a ^ b)
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of bitwiseXnor().See bitwiseXnor() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See bitwiseXnor() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 ofB
.- Parameters
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().
- Returns
A tensor where each element is equal to a << b, where
a
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of shiftLeft().See shiftLeft() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See shiftLeft() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 ofB
.- Parameters
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().
- Returns
A tensor where each element is equal to a >> b (without sign extension), where
a
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of shiftRight().See shiftRight() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See shiftRight() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 ofB
.- Parameters
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().
- Returns
A tensor where each element is equal to
a >> b
with sign extension, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of shiftRightSignExtend().See shiftRightSignExtend() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See shiftRightSignExtend() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the results to.
Unnamed Group
-
inline 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 inA
with the corresponding element inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a && b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of logicalAnd().See logicalAnd() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See logicalAnd() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the booleans to.
Unnamed Group
-
inline 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 inA
with the corresponding element inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a || b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of logicalOr().See logicalOr() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See logicalOr() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the booleans to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a == b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
Unnamed Group
-
inline 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,
out
.See eq() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the booleans to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a != b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
Unnamed Group
-
inline 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 tensor
A
with the result of neq().See neq() for parameter descriptions.
Unnamed Group
-
inline 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,
out
.See neq() for the remaining parameter descriptions.
- Parameters
out – The tensor to write the booleans to.
Unnamed Group
-
inline 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 inB
.- Parameters
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().
- Returns
A tensor where each element is the result of
a >= b
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})