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 on 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.
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
-
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 = {})
- 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 = {})
mapInPlace
Update the input tensors with the result of map().
-
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 = {})
-
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 = {})
mapWithOutput
Write the result of map() to the given output tensor.
-
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 = {})
-
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 = {})
checkTypes
Check that the host compile-time type
constType
is compatible with the run-time IPU typeelementType
.- 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)
, wherevariance_value
is the corresponding element invariance
.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.
-
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 = {})
-
poplar::Tensor varianceToInvStdDev(poplar::Graph &graph, const poplar::Tensor &src, const float epsilon, poplar::program::Sequence &prog, const poplar::Type dstType = poplar::HALF, const poplar::DebugContext &debugContext = {})
-
inline poplar::Tensor varianceToInvStdDev(poplar::Graph &graph, const poplar::Tensor &variance, const poplar::Tensor &epsilon, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {}, const poplar::OptionFlags &options = {})
invStdDevToVariance
Convert inverse standard deviation to variance.
Each element in the output tensor is the result of
1 / (invStdDev_value + epsilon)^2
, whereinvStdDev_value
is the corresponding element ininvStdDev
.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.
-
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 = {})
-
poplar::Tensor invStdDevToVariance(poplar::Graph &graph, const poplar::Tensor &src, const float epsilon, poplar::program::Sequence &prog, const poplar::Type dstType = poplar::FLOAT, const poplar::DebugContext &debugContext = {})
-
inline poplar::Tensor invStdDevToVariance(poplar::Graph &graph, const poplar::Tensor &invStdDev, const poplar::Tensor &epsilon, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext = {}, const poplar::OptionFlags &options = {})
add
Add each element in
A
to the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
sub
Subtract the elements of
B
fromA
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
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
mul
Multiply each element in
A
by the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
div
Divide each element in
A
by the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
pow
Compute each element in
A
to the power of the corresponding element inB
.- 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)
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
rem
Compute the remainder of each element in
A
divided by the corresponding element inB
.- 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
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
bitwiseAnd
Compute the bitwise AND of each element in
A
with the corresponding element inB
.- 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
, wherea
andbare
the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
bitwiseOr
Compute the bitwise OR of each element in
A
with the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
bitwiseXor
Compute the bitwise XOR of each element in
A
with the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
bitwiseXnor
Compute the bitwise XNOR of each element in
A
with the corresponding element inB
.- 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)
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
shiftLeft
Shift the elements of
A
left by the corresponding elements ofB
.- 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
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
shiftRight
Shift the elements of
A
right by the corresponding elements ofB
.- 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
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
shiftRightSignExtend
Shift the elements of
A
right with sign extension by the corresponding elements ofB
.- 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, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
logicalAnd
Compute the logical AND (
&&
) of each element inA
with the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
logicalOr
Compute the logical OR (
||
) of each element inA
with the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
eq
Check if each element in
A
is equal to the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.
-
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 = {})
neq
Check if each element in
A
is not equal to the corresponding element inB
.- 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
, wherea
andb
are the corresponding elements ofA
andB
tensors respectively.
-
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 = {})
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.