Poplar and PopLibs
popnn::pooling Namespace Reference

Functions for pooling operations. More...

Functions

poplar::Tensor pool (poplar::Graph &graph, const PoolParams &params, const poplar::Tensor &in, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Add a pooling operation to the graph. More...
 
poplar::Tensor poolInputGradient (poplar::Graph &graph, const PoolParams &params, const poplar::Tensor &in, const poplar::Tensor &pooled, const poplar::Tensor &pooledGradient, bool useScaledGradient, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Calculate the gradient with respect to the input of a pooling operation given the gradient of the output. More...
 
poplar::Tensor poolInputGradient (poplar::Graph &graph, const PoolParams &params, const unsigned fwdChansPerGroup, const poplar::Tensor &pooledGradient, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Calculate the gradient with respect to the input of a pooling operation given the gradient of the output. More...
 

Detailed Description

Functions for pooling operations.

Function Documentation

◆ pool()

poplar::Tensor popnn::pooling::pool ( poplar::Graph graph,
const PoolParams &  params,
const poplar::Tensor in,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Add a pooling operation to the graph.

This performs a pooling over the spatial dimensions [...]. The shape of the input should be [batchSize * numChannels * ...].

Parameters
graphThe graph that the operation will be added to.
paramsThe pooling parameters.
inThe input tensor.
progThe program sequence to append the operation to.
debugContextOptional debug information.
optionsPooling options (not currently used).
Returns
A tensor with the results of the pooling operation.

◆ poolInputGradient() [1/2]

poplar::Tensor popnn::pooling::poolInputGradient ( poplar::Graph graph,
const PoolParams &  params,
const poplar::Tensor in,
const poplar::Tensor pooled,
const poplar::Tensor pooledGradient,
bool  useScaledGradient,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Calculate the gradient with respect to the input of a pooling operation given the gradient of the output.

While this function can be used for maximum, average or sum pooling, poolInputGradient(poplar::Graph&, const PoolParams&, const unsigned, const poplar::Tensor&, poplar::program::Sequence&, const poplar::DebugContext&, const poplar::OptionFlags&) is recommended for average or sum pooling.

This performs a pooling over the spatial dimensions [...]. The shape of the input should be [batchSize * numChannels * ...].

Parameters
graphThe graph the operation will be added to.
paramsThe pooling parameters.
inThe forward activations tensor input to pooling.
pooledThe output of pooling in the forward pass.
pooledGradientThe gradients to the pooling operation.
useScaledGradientUse a scaled gradient if set to true. Otherwise, the gradient is propagated to all the positions which matched the pooled value in the forward pass.
progThe program sequence to append the operation to.
debugContextOptional debug information.
optionsThe pooling options. See pool().
Returns
A tensor with the results of the pooling operation.

◆ poolInputGradient() [2/2]

poplar::Tensor popnn::pooling::poolInputGradient ( poplar::Graph graph,
const PoolParams &  params,
const unsigned  fwdChansPerGroup,
const poplar::Tensor pooledGradient,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {} 
)

Calculate the gradient with respect to the input of a pooling operation given the gradient of the output.

This function should be used for average and sum pooling.

This performs a pooling over the spatial dimensions [...]. The shape of the output will be [batchSize * numChannels * ...].

Parameters
graphThe graph the operation will be added to.
paramsThe pooling parameters.
fwdChansPerGroupUsed in creating the output tensor.
pooledGradientThe gradients to the pooling operation.
progThe program sequence to append the operation to.
debugContextOptional debug information.
optionsThe pooling options. See pool().
Returns
A tensor with the results of the pooling operation.