11#include <poplar/Graph.hpp>
12#include <poplar/Program.hpp>
13#include <poplar/Tensor.hpp>
58 std::size_t getInputBytesPerTile(
const poplar::Graph &graph)
const;
61 std::size_t getOutputBytesPerTile(
const poplar::Graph &graph)
const;
64 bool variableTimeSteps()
const;
67 bool batchVariableTimeSteps()
const;
90 unsigned multiple,
unsigned numShards,
106 unsigned size,
unsigned numShards,
159 unsigned multiple,
unsigned numShards,
193 std::vector<poplar::Tensor> inputs;
196 std::vector<poplar::Tensor> outputs;
202struct RnnBatchwiseFlags {
206 bool valid()
const {
return mask.valid(); };
209struct TimeStepState {
235 poplar::Graph &graph,
const TimeStepState &time,
const RnnBatchwiseFlags &,
236 std::vector<poplar::Tensor> &,
const RnnSlice &slice,
266 std::size_t stateIndex;
304std::vector<poplar::Tensor>
306 const std::vector<poplar::Tensor> &initState,
308 const std::vector<poplar::Tensor> &inputs,
const poplar::Tensor *interimIn,
309 poplar::Tensor *interimOut,
const std::vector<poplar::Tensor> &outputs,
357std::vector<poplar::Tensor>
359 const std::vector<poplar::Tensor> &initState,
361 const std::vector<poplar::Tensor> &inputs,
const poplar::Tensor &interimIn,
363 const LoopBodyType &loopFn,
const std::vector<poplar::Tensor> &gatherInputs,
364 const GatherBodyType &gatherFn,
unsigned numShards,
unsigned stepsPerGather,
Poplibs generic debug info structure.
DebugContext gathers the common external parameters of the context of an operation.
Definition: DebugContext.hpp:221
DebugNameAndId bundles a name and a DebugId to facilitate their propagation through function calls.
Definition: DebugContext.hpp:142
This class represents a graph program to be executed on the IPU.
Definition: Graph.hpp:52
A set of option/value string flags to be used in various APIs.
Definition: OptionFlags.hpp:24
A reference to a subset of tensor elements.
Definition: Tensor.hpp:38
Class representing device data types.
Definition: Type.hpp:42
Program that executes a sequence of programs.
Definition: Program.hpp:77
poplar::Tensor createRecurrentTensor(poplar::Graph &graph, const RnnParams ¶ms, unsigned size, unsigned numShards, const poplar::DebugContext &debugContext={})
Create recurrent tensor of shape [timeSteps, batchSize, size] suitable for slicing and/or sharding of...
poplar::Tensor createOutputTensor(poplar::Graph &graph, const RnnParams ¶ms, unsigned numShards, const poplar::DebugContext &debugContext={})
Create a standard output tensor of shape [timeSteps, batchSize, outputSize] suitable for slicing and/...
poplar::Tensor shiftRnnTensor(poplar::Graph &graph, const RnnParams ¶ms, const poplar::Tensor &tBase, const poplar::Tensor &tSingle, poplar::program::Sequence &prog, unsigned numShards, const poplar::DebugContext &debugContext={})
Create a single-step shifted RNN tensor from an input tensor.
poplar::Tensor createInputTensor(poplar::Graph &graph, const RnnParams ¶ms, unsigned numShards, const poplar::DebugContext &debugContext={})
Create input tensor of shape [timeSteps, batchSize, inputSize] suitable for slicing and/or sharding o...
std::vector< poplar::Tensor > Rnn(poplar::Graph &graph, const RnnParams ¶ms, bool reverse, const std::vector< poplar::Tensor > &initState, const StateSequence &stateSequence, const std::vector< poplar::Tensor > &inputs, const poplar::Tensor *interimIn, poplar::Tensor *interimOut, const std::vector< poplar::Tensor > &outputs, const std::vector< poplar::Tensor > &created, poplar::program::Sequence &prog, const LoopBodyType &loopFn, unsigned numShards, poplar::OptionFlags &options, const poplar::DebugContext &debugContext={})
Run custom Recurrent Neural Net cell implementation recurrently.
poplar::Tensor createInitialState(poplar::Graph &graph, const RnnParams ¶ms, bool isOutput, unsigned multiple, unsigned numShards, const poplar::DebugContext &debugContext={})
Create state tensor to be used in all recurrences of the RNN.
std::function< poplar::program::Sequence(poplar::Graph &graph, const TimeStepState &time, const RnnBatchwiseFlags &, std::vector< poplar::Tensor > &, const RnnSlice &slice, std::vector< poplar::Tensor > &, poplar::program::Sequence *, const poplar::DebugNameAndId &)> LoopBodyType
Create loop body function for the given shard.
Definition: Rnn.hpp:238
std::function< poplar::program::Sequence(poplar::Graph &graph, const RnnSlice &slice, unsigned stepsPerGather, poplar::program::Sequence *, const poplar::DebugNameAndId &)> GatherBodyType
Create gather body function for the given shard.
Definition: Rnn.hpp:253
Functions used in neural networks.
Definition: BatchNorm.hpp:14
Structure of Recurrent Neural Network (RNN) parameters which allows for any customized implementation...
Definition: Rnn.hpp:22
std::size_t maxTimeSteps
The maximum number of RNN time steps.
Definition: Rnn.hpp:30
std::vector< std::size_t > layerSizes
For each RNN layer, the layer size parameter needs to be specified for the input and the output.
Definition: Rnn.hpp:45
poplar::Type dataType
The datatype used for the RNN.
Definition: Rnn.hpp:24
std::size_t timeSteps
Definition: Rnn.hpp:33
poplar::Tensor varTimeSteps
The run-time number of RNN time steps of dimension [batchSize] If this tensor is default constructed,...
Definition: Rnn.hpp:39
std::size_t batchSize
The batch size.
Definition: Rnn.hpp:27
Tensors required for processing a single time step.
Definition: Rnn.hpp:192
Structure that associates a particular state tensor with a user-defined output tensor.
Definition: Rnn.hpp:264