Poplar and PopLibs
Recurrent.hpp File Reference

Functions for recurrent neural networks (RNN). More...

#include <poplar/Graph.hpp>
#include <poplar/Program.hpp>
#include <popnn/NonLinearity.hpp>

Go to the source code of this file.

Namespaces

namespace  poplin
 Linear algebra functions.
 
namespace  popnn
 Functions used in neural networks.
 
namespace  popnn::rnn
 Functions for Recurrent Neural Networks (RNN)
 

Functions

std::vector< std::pair< poplin::MatMulParams, poplar::OptionFlags > > popnn::rnn::getMatMulPrePlanParameters (std::size_t numSteps, std::size_t batchSize, std::size_t inputSize, std::size_t outputSize, const poplar::Type &dType, const poplar::Type &partialsType=poplar::FLOAT, bool inferenceOnly=false, bool hasFeedforwardWeights=true)
 Predict what matrix multiplications will be needed for the given parameters and return list of corresponding matmul parameters and options.
 
uint64_t popnn::rnn::getFwdFlops (unsigned sequenceSize, unsigned batchSize, unsigned inputSize, unsigned outputSize, bool weightInput=true)
 Compute the total floating point operations for the forward pass of RNN.
 
uint64_t popnn::rnn::getBwdFlops (unsigned sequenceSize, unsigned batchSize, unsigned inputSize, unsigned outputSize, bool calcInputGrad=true)
 Compute the total floating point operations for the backward pass of RNN.
 
uint64_t popnn::rnn::getWuFlops (unsigned sequenceSize, unsigned batchSize, unsigned inputSize, unsigned outputSize)
 Compute the total floating point operations for the weight update pass of RNN.
 
poplar::Tensor popnn::rnn::createInput (poplar::Graph &graph, unsigned numSteps, unsigned batchSize, unsigned inputSize, unsigned outputSize, const poplar::Type &dType, const poplar::Type &partialsType=poplar::FLOAT, bool inferenceOnly=false, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Create a tensor which is input to a vanilla RNN. More...
 
poplar::Tensor popnn::rnn::createFwdState (poplar::Graph &graph, const poplar::Type &dType, unsigned batchSize, unsigned outputSize, poplar::program::Sequence &prog, bool initState, bool inferenceOnly, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Create initial state for a vanilla RNN. More...
 
poplar::Tensor popnn::rnn::getOutputFromFwdState (const poplar::Tensor &fwdState)
 Extract previous output tensor from the hidden state. More...
 
poplar::Tensor popnn::rnn::createWeightsInput (poplar::Graph &graph, unsigned sequenceSize, unsigned batchSize, unsigned inputSize, unsigned outputSize, const poplar::Type &dType, const poplar::Type &partialsType=poplar::FLOAT, bool inferenceOnly=false, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Create the weights used to weight the input of a vanilla RNN layer. More...
 
poplar::Tensor popnn::rnn::createWeightsFeedback (poplar::Graph &graph, unsigned batchSize, unsigned outputSize, const poplar::Type &dType, const poplar::Type &partialsType=poplar::FLOAT, bool inferenceOnly=false, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Create the weights used in the recurrent part of a vanilla RNN layer. More...
 
poplar::Tensor popnn::rnn::forwardWeightInput (poplar::Graph &graph, const poplar::Tensor &actIn, const poplar::Tensor &weights, poplar::program::Sequence &prog, const poplar::Type &partialsType=poplar::FLOAT, bool inferenceOnly=false, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Perform the feedforward part of a RNN layer. More...
 
poplar::Tensor popnn::rnn::forwardIterate (poplar::Graph &graph, const poplar::Tensor &feedFwdIn, const poplar::Tensor &initState, const poplar::Tensor &feedbackWeights, const poplar::Tensor &biases, poplar::program::Sequence &prog, popnn::NonLinearityType nonLinearityType, const poplar::Type &partialsType=poplar::FLOAT, bool inferenceOnly=false, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Perform the feedback part of the RNN layer. More...
 
poplar::Tensor popnn::rnn::createBwdState (poplar::Graph &graph, const poplar::Type &dType, unsigned batchSize, unsigned outputSize, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Create initial state for backward pass of a vanilla RNN. More...
 
std::pair< poplar::Tensor, poplar::Tensorpopnn::rnn::backwardGradientStep (poplar::Graph &graph, const poplar::Tensor &nextLayerGrad, const poplar::Tensor &bwdState, const poplar::Tensor &actOut, const poplar::Tensor &weightsInput, const poplar::Tensor &weightsFeedback, poplar::program::Sequence &prog, popnn::NonLinearityType nonLinearityType, const poplar::Type &partialsType=poplar::FLOAT, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Compute a single step of the backward pass of a vanilla RNN layer. More...
 
poplar::Tensor popnn::rnn::backwardGradientStep (poplar::Graph &graph, const poplar::Tensor &nextLayerGrad, const poplar::Tensor &bwdState, const poplar::Tensor &actOut, const poplar::Tensor &weightsFeedback, poplar::program::Sequence &prog, popnn::NonLinearityType nonLinearityType, const poplar::Type &partialsType=poplar::FLOAT, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Same as backwardGradientStep(poplar::Graph&, const poplar::Tensor&, const poplar::Tensor&, const poplar::Tensor&, const poplar::Tensor&, const poplar::Tensor &, poplar::program::Sequence&, popnn::NonLinearityType, const poplar::Type&, const poplar::DebugContext&, poplin::PlanningCache*) with the difference that the input gradients are not computed.
 
void popnn::rnn::paramDeltaUpdate (poplar::Graph &graph, const poplar::Tensor &bwdState, const poplar::Tensor &actIn, const poplar::Tensor &prevOut, poplar::Tensor &weightsInputDeltasAcc, poplar::Tensor &weightsFeedbackDeltasAcc, poplar::Tensor &biasDeltasAcc, poplar::program::Sequence &prog, const poplar::Type &partialsType=poplar::FLOAT, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Update parameter deltas for a vanilla RNN step. More...
 
poplar::Tensor popnn::rnn::rnnFwdSequence (poplar::Graph &graph, poplar::program::Sequence &prog, const poplar::Tensor &fwdStateInit, const poplar::Tensor *weightedIn, const poplar::Tensor &biases, const poplar::Tensor &feedFwdWeights, const poplar::Tensor &feedbackWeights, const poplar::Tensor &prevLayerActs, const popnn::NonLinearityType &nonLinearityType, const poplar::Type &partialsType, bool inferenceOnly, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Perform the forward part of the RNN layer. More...
 
std::tuple< poplar::Tensor, poplar::Tensor, poplar::Tensor, poplar::Tensorpopnn::rnn::rnnBwdSequence (poplar::Graph &graph, bool doWU, bool ignoreInputGradientCalc, poplar::program::Sequence &prog, const poplar::Tensor &fwdStateInit, const poplar::Tensor &fwdState, const poplar::Tensor &biases, const poplar::Tensor &feedFwdWeights, const poplar::Tensor &feedbackWeights, const poplar::Tensor &outGradient, const poplar::Tensor &actIn, const popnn::NonLinearityType &nonLinearityType, const poplar::Type &partialsType, const poplar::DebugContext &debugContext={}, poplin::PlanningCache *planningCache=nullptr)
 Perform the feedback part of the RNN layer. More...
 

Detailed Description

Functions for recurrent neural networks (RNN).