Poplar and PopLibs
MultiConvolution.hpp File Reference

Support performing convolutions in parallel. More...

#include "poplin/Convolution.hpp"
#include <poplar/Graph.hpp>
#include <poplar/OptionFlags.hpp>
#include <poplar/Program.hpp>
#include <vector>

Go to the source code of this file.

Classes

struct  poplin::multiconv::CreateTensorArgs
 Multi-convolutions allow for a set of convolutions to be executed in parallel. More...
 
struct  poplin::multiconv::ConvolutionArgs
 
struct  poplin::multiconv::CalculateWeightDeltasArgs
 
struct  poplin::multiconv::ConvWeightUpdateArgs
 
struct  poplin::multiconv::ConvWeightUpdateArgsScalar
 

Namespaces

namespace  poplin
 Linear algebra functions.
 

Functions

poplar::Tensor poplin::multiconv::createWeights (poplar::Graph &graph, const std::vector< CreateTensorArgs > &args, unsigned weightsIndex, const poplar::OptionFlags &options={}, poplin::PlanningCache *cache=nullptr)
 Create a specific weights tensor for the multiconvolution. More...
 
poplar::Tensor poplin::multiconv::createInput (poplar::Graph &graph, const std::vector< CreateTensorArgs > &args, unsigned inputIndex, const poplar::OptionFlags &options={}, poplin::PlanningCache *cache=nullptr)
 Create a specific input tensor for the multiconvolution. More...
 
void poplin::multiconv::weightsTransposeChansFlipXY (poplar::Graph &graph, std::vector< ConvolutionArgs > &args, const std::vector< poplar::Tensor > &weightsIn, poplar::program::Sequence &prog, const poplar::OptionFlags &options, const poplar::DebugContext &debugContext, poplin::PlanningCache *cache)
 For each element in the multi-convolution set, copy the corresponding weightsIn element into the convolution weight input such that each element of the kernel is transposed with respect to the input and output channels and each spatial dimension of the kernel is flipped. More...
 
std::vector< poplar::Tensorpoplin::multiconv::convolution (poplar::Graph &graph, const std::vector< ConvolutionArgs > &args, bool transposeAndFlipWeights, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, poplin::PlanningCache *cache=nullptr)
 Convolve a set of inputs with a set of weights. More...
 
std::vector< poplar::Tensorpoplin::multiconv::calculateWeightDeltas (poplar::Graph &graph, const std::vector< CalculateWeightDeltasArgs > &args, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, poplin::PlanningCache *cache=nullptr)
 Append an operation to generate the set of weight delta tensors. More...
 
void poplin::multiconv::convolutionWeightUpdate (poplar::Graph &graph, const std::vector< ConvWeightUpdateArgs > &args, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, poplin::PlanningCache *cache=nullptr)
 Append operations to prog to generate and apply the weight update. More...
 
void poplin::multiconv::convolutionWeightUpdate (poplar::Graph &graph, const std::vector< ConvWeightUpdateArgsScalar > &args, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={}, poplin::PlanningCache *cache=nullptr)
 Append operations to prog to generate and apply the weight update. More...
 

Detailed Description

Support performing convolutions in parallel.

Function Documentation

◆ calculateWeightDeltas()

std::vector< poplar::Tensor > poplin::multiconv::calculateWeightDeltas ( poplar::Graph graph,
const std::vector< CalculateWeightDeltasArgs > &  args,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {},
poplin::PlanningCache *  cache = nullptr 
)

Append an operation to generate the set of weight delta tensors.

See Convolution.hpp for more information.

Parameters
graphThe graph that the operations will be added to.
argsCollection of zDeltas, activations, and convolution parameters specifying each convolution in the multiconvolution.
progPoplar program sequence to append the operations onto.
debugContextOptional debug information.
optionsOptions controlling the implementation.
cacheOptional pointer to a planning cache to use.
Returns
Set of weight deltas.

◆ convolution()

std::vector< poplar::Tensor > poplin::multiconv::convolution ( poplar::Graph graph,
const std::vector< ConvolutionArgs > &  args,
bool  transposeAndFlipWeights,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {},
poplin::PlanningCache *  cache = nullptr 
)

Convolve a set of inputs with a set of weights.

See Convolution.hpp for more information.

Parameters
graphThe graph that the operations will be added to.
argsCollection of inputs, weights, and convolution parameters specifying each convolution in the multiconvolution.
transposeAndFlipWeightsPrepare the weights for the backwards pass.
progPoplar program sequence to append the operations onto.
debugContextOptional debug information.
optionsOptions controlling the implementation.
cacheOptional pointer to a planning cache to use.
Returns
Set of convolved output tensors.

◆ convolutionWeightUpdate() [1/2]

void poplin::multiconv::convolutionWeightUpdate ( poplar::Graph graph,
const std::vector< ConvWeightUpdateArgs > &  args,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {},
poplin::PlanningCache *  cache = nullptr 
)

Append operations to prog to generate and apply the weight update.

See Convolution.hpp for more information.

Parameters
graphThe graph that the operations will be added to.
argsCollection of zDeltas, activations, scale, and convolution parameters for the weight updates in the multiconvolution.
progPoplar program sequence to append the operations onto.
debugContextOptional debug information.
optionsOptions controlling the implementation.
cacheOptional pointer to a planning cache to use.

◆ convolutionWeightUpdate() [2/2]

void poplin::multiconv::convolutionWeightUpdate ( poplar::Graph graph,
const std::vector< ConvWeightUpdateArgsScalar > &  args,
poplar::program::Sequence prog,
const poplar::DebugContext debugContext = {},
const poplar::OptionFlags options = {},
poplin::PlanningCache *  cache = nullptr 
)

Append operations to prog to generate and apply the weight update.

See Convolution.hpp for more information.

Parameters
graphThe graph that the operations will be added to.
argsCollection of zDeltas, activations, scale, and convolution parameters for the weight updates in the multiconvolution.
progPoplar program sequence to append the operations onto.
debugContextOptional debug information.
optionsOptions controlling the implementation.
cacheOptional pointer to a planning cache to use.

◆ createInput()

poplar::Tensor poplin::multiconv::createInput ( poplar::Graph graph,
const std::vector< CreateTensorArgs > &  args,
unsigned  inputIndex,
const poplar::OptionFlags options = {},
poplin::PlanningCache *  cache = nullptr 
)

Create a specific input tensor for the multiconvolution.

Parameters
graphThe graph that the tensors will be added to.
argsThe same set of parameters as used by convolution().
inputIndexIndex into args describing the convolution which to create the input for.
optionsOptions controlling the implementation.
cacheOptional pointer to a planning cache to use.
Returns
A tensor suitable for use as an input to convolution().

◆ createWeights()

poplar::Tensor poplin::multiconv::createWeights ( poplar::Graph graph,
const std::vector< CreateTensorArgs > &  args,
unsigned  weightsIndex,
const poplar::OptionFlags options = {},
poplin::PlanningCache *  cache = nullptr 
)

Create a specific weights tensor for the multiconvolution.

Parameters
graphThe graph that the tensors will be added to.
argsThe same set of parameters as used by convolution().
weightsIndexIndex into args describing the convolution which to create the weights for.
optionsOptions controlling the implementation.
cacheOptional pointer to a planning cache to use.
Returns
A weights tensor suitable for use with convolution().

◆ weightsTransposeChansFlipXY()

void poplin::multiconv::weightsTransposeChansFlipXY ( poplar::Graph graph,
std::vector< ConvolutionArgs > &  args,
const std::vector< poplar::Tensor > &  weightsIn,
poplar::program::Sequence prog,
const poplar::OptionFlags options,
const poplar::DebugContext debugContext,
poplin::PlanningCache *  cache 
)

For each element in the multi-convolution set, copy the corresponding weightsIn element into the convolution weight input such that each element of the kernel is transposed with respect to the input and output channels and each spatial dimension of the kernel is flipped.

See Convolution.hpp for more information.

Parameters
graphThe graph that the operations will be added to.
argsCollection of inputs, weights, and convolution parameters specifying each convolution in the multiconvolution.
weightsInCollection of weights tensor to copy from, the arrangement of which must correspond with the arrangement of the collection of convolution parameters.
progPoplar program sequence to append the operations onto.
optionsOptions controlling the implementation.
debugContextOptional debug information.
cacheOptional pointer to a planning cache to use.