NormaliseImage
#include <popops/NormaliseImage.hpp>
Functions for padding and normalising image tensors.
-
namespace popops
Common functions, such as elementwise and reductions.
Functions
-
poplar::Tensor createNormaliseImageInput(poplar::Graph &graph, const poplar::Type &type, const poplar::ArrayRef<std::size_t> shape, const poplar::DebugContext &debugContext = {})
Add a tensor for a 3-channel image suitable for padding to 4 channels.
- Parameters
graph – The graph to which the tensor will be added.
type – The type of the elements. Must be
UNSIGNED_CHAR
,HALF
orFLOAT
.shape – Required tensor shape. Must have an inner dimension of three.
debugContext – Debugging context.
-
poplar::Tensor normaliseImage(poplar::Graph &graph, poplar::program::Sequence &seq, poplar::Tensor tIn, float inScale, poplar::Tensor offsets, poplar::Tensor scales, const poplar::DebugContext &debugContext = {})
Pad a tensor to have 4 channel dimensions.
Each channel is normalised via:
tIn[c] * inScale - offset[c]) * scale[c]
tIn must be mapped with a single region of complete pixels on each tile. createNormaliseImageInput() creates a variable that is suitably mapped.
UINT8
inputs are cast toHALF
. Otherwise the output tensor follows the input type.- Parameters
graph – The graph containing the tensor.
seq – The sequence to which the normalisation programs will be added.
tIn – Input image. It must have an inner dimension of 3. and be
UNSIGNED_CHAR
,HALF
orFLOAT
.inScale – Input scaling.
offsets – Offset for each channel. Must be shape {3} and must match the output type.
scales – Scaling factor for each channel. Must be shape {3} and must match the output type.
debugContext – Debugging context.
-
poplar::Tensor createNormaliseImageInput(poplar::Graph &graph, const poplar::Type &type, const poplar::ArrayRef<std::size_t> shape, const poplar::DebugContext &debugContext = {})