Poplar and PopLibs
|
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::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. More... | |
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. 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... | |
Support performing convolutions in parallel.
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.
graph | The graph that the operations will be added to. |
args | Collection of zDeltas, activations, and convolution parameters specifying each convolution in the multiconvolution. |
prog | Poplar program sequence to append the operations onto. |
debugContext | Optional debug information. |
options | Options controlling the implementation. |
cache | Optional pointer to a planning cache to use. |
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.
graph | The graph that the operations will be added to. |
args | Collection of inputs, weights, and convolution parameters specifying each convolution in the multiconvolution. |
transposeAndFlipWeights | Prepare the weights for the backwards pass. |
prog | Poplar program sequence to append the operations onto. |
debugContext | Optional debug information. |
options | Options controlling the implementation. |
cache | Optional pointer to a planning cache to use. |
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.
graph | The graph that the operations will be added to. |
args | Collection of zDeltas, activations, scale, and convolution parameters for the weight updates in the multiconvolution. |
prog | Poplar program sequence to append the operations onto. |
debugContext | Optional debug information. |
options | Options controlling the implementation. |
cache | Optional pointer to a planning cache to use. |
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.
graph | The graph that the operations will be added to. |
args | Collection of zDeltas, activations, scale, and convolution parameters for the weight updates in the multiconvolution. |
prog | Poplar program sequence to append the operations onto. |
debugContext | Optional debug information. |
options | Options controlling the implementation. |
cache | Optional pointer to a planning cache to use. |
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.
graph | The graph that the tensors will be added to. |
args | The same set of parameters as used by convolution(). |
inputIndex | Index into args describing the convolution which to create the input for. |
options | Options controlling the implementation. |
cache | Optional pointer to a planning cache to use. |
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.
graph | The graph that the tensors will be added to. |
args | The same set of parameters as used by convolution(). |
weightsIndex | Index into args describing the convolution which to create the weights for. |
options | Options controlling the implementation. |
cache | Optional pointer to a planning cache to use. |
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.
graph | The graph that the operations will be added to. |
args | Collection of inputs, weights, and convolution parameters specifying each convolution in the multiconvolution. |
weightsIn | Collection of weights tensor to copy from, the arrangement of which must correspond with the arrangement of the collection of convolution parameters. |
prog | Poplar program sequence to append the operations onto. |
options | Options controlling the implementation. |
debugContext | Optional debug information. |
cache | Optional pointer to a planning cache to use. |