104 if (!m_Param.m_CifgEnabled)
114 if (m_Param.m_ProjectionEnabled)
122 if (m_Param.m_PeepholeEnabled)
124 if (!m_Param.m_CifgEnabled)
135 if (m_Param.m_LayerNormEnabled)
147 return std::move(layer);
155 unsigned int batchSize = inputShapes[0][0];
156 unsigned int outputSize = inputShapes[1][1];
157 unsigned int numUnits = inputShapes[2][1];
159 std::vector<TensorShape> outShapes;
161 outShapes.push_back(
TensorShape({batchSize, outputSize}));
162 outShapes.push_back(
TensorShape({batchSize, numUnits}));
163 outShapes.push_back(
TensorShape({batchSize, outputSize}));
186 "LstmLayer: m_BasicParameters.m_InputToForgetWeights should not be null.");
188 "LstmLayer: m_BasicParameters.m_InputToCellWeights should not be null.");
190 "LstmLayer: m_BasicParameters.m_InputToOutputWeights should not be null.");
192 "LstmLayer: m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
194 "LstmLayer: m_BasicParameters.m_RecurrentToCellWeights should not be null.");
196 "LstmLayer: m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
198 "LstmLayer: m_BasicParameters.m_ForgetGateBias should not be null.");
200 "LstmLayer: m_BasicParameters.m_CellBias should not be null.");
202 "LstmLayer: m_BasicParameters.m_OutputGateBias should not be null.");
207 "LstmLayer: m_CifgParameters.m_InputToInputWeights should not be null.");
209 "LstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not be null.");
211 "LstmLayer: m_CifgParameters.m_InputGateBias should not be null.");
218 "LstmLayer: m_CifgParameters.m_InputToInputWeights should not have a value when CIFG is enabled.");
220 "LstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not have a value when CIFG is enabled.");
222 "LstmLayer: m_CifgParameters.m_InputGateBias should not have a value when CIFG is enabled.");
230 "LstmLayer: m_ProjectionParameters.m_ProjectionWeights should not be null.");
238 "LstmLayer: m_PeepholeParameters.m_CellToInputWeights should not be null " 239 "when Peephole is enabled and CIFG is disabled.");
242 "LstmLayer: m_PeepholeParameters.m_CellToForgetWeights should not be null.");
244 "LstmLayer: m_PeepholeParameters.m_CellToOutputWeights should not be null.");
259 "LstmLayer: m_LayerNormParameters.m_inputLayerNormWeights should not be null.");
262 "LstmLayer: m_LayerNormParameters.m_forgetLayerNormWeights should not be null.");
264 "LstmLayer: m_LayerNormParameters.m_cellLayerNormWeights should not be null.");
266 "LstmLayer: m_LayerNormParameters.m_outputLayerNormWeights should not be null.");
340 managedInputToInputWeights.
Map());
341 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
348 managedInputToForgetWeights.
Map());
349 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
356 managedInputToCellWeights.
Map());
357 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
364 managedInputToOutputWeights.
Map());
365 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
373 managedRecurrentToInputWeights.
Map());
374 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
382 managedRecurrentToForgetWeights.
Map());
383 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
391 managedRecurrentToCellWeights.
Map());
392 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
400 managedRecurrentToOutputWeights.
Map());
401 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
408 managedCellToInputWeights.
Map());
409 cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
416 managedCellToForgetWeights.
Map());
417 cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
424 managedCellToOutputWeights.
Map());
425 cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
432 managedInputGateBias.
Map());
433 inputGateBiasTensor = inputGateBiasTensorCopy;
440 managedForgetGateBias.
Map());
441 forgetGateBiasTensor = forgetGateBiasTensorCopy;
448 managedCellBias.
Map());
449 cellBiasTensor = cellBiasTensorCopy;
456 managedOutputGateBias.
Map());
457 outputGateBias = outputGateBiasCopy;
464 managedProjectionWeights.
Map());
465 projectionWeightsTensor = projectionWeightsTensorCopy;
472 managedProjectionBias.
Map());
473 projectionBiasTensor = projectionBiasTensorCopy;
480 managedInputLayerNormWeights.
Map());
481 inputLayerNormTensor = inputLayerNormTensorCopy;
488 managedForgetLayerNormWeights.
Map());
489 forgetLayerNormTensor = forgetLayerNormTensorCopy;
496 managedCellLayerNormWeights.
Map());
497 cellLayerNormTensor = cellLayerNormTensorCopy;
504 managedOutputLayerNormWeights.
Map());
505 outputLayerNormTensor = outputLayerNormTensorCopy;
515 std::vector<ConstTensor> constTensors;
553 managedInputToForgetWeights.
Map()));
558 managedInputToCellWeights.
Map()));
563 managedInputToOutputWeights.
Map()));
569 managedRecurrentToForgetWeights.
Map()));
575 managedRecurrentToCellWeights.
Map()));
581 managedRecurrentToOutputWeights.
Map()));
586 managedForgetGateBias.
Map()));
591 managedCellBias.
Map()));
596 managedOutputGateBias.
Map()));
605 managedInputToInputWeights.
Map()));
611 managedRecurrentToInputWeights.
Map()));
616 managedInputGateBias.
Map()));
628 managedCellToInputWeights.
Map()));
634 managedCellToForgetWeights.
Map()));
639 managedCellToOutputWeights.
Map()));
649 managedProjectionWeights.
Map()));
654 managedProjectionBias.
Map()));
666 managedInputLayerNormWeights.
Map()));
672 managedForgetLayerNormWeights.
Map()));
677 managedCellLayerNormWeights.
Map()));
682 managedOutputLayerNormWeights.
Map()));
std::shared_ptr< ConstTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_OutputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
bool m_ProjectionEnabled
Enable/disable the projection layer.
LstmBasicParameters m_BasicParameters
const ConstTensorHandle * m_ProjectionWeights
const ConstTensorHandle * m_RecurrentToForgetWeights
std::shared_ptr< ConstTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
LstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const LstmDescriptor & GetParameters() const
const TensorShape & GetShape() const
const ConstTensorHandle * m_InputGateBias
const ConstTensorHandle * m_RecurrentToCellWeights
virtual void VisitLstmLayer(const IConnectableLayer *layer, const LstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)=0
Function an Lstm layer should call back to when its Accept(ILayerVisitor&) function is invoked...
const ConstTensorHandle * m_CellBias
virtual void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
virtual std::unique_ptr< IWorkload > CreateLstm(const LstmQueueDescriptor &descriptor, const WorkloadInfo &info) const
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the LSTM type.
const ConstTensorHandle * m_InputToOutputWeights
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
const ConstTensorHandle * m_OutputLayerNormWeights
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
const TensorInfo & GetTensorInfo() const
Copyright (c) 2021 ARM Limited and Contributors.
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
This layer represents a LSTM operation.
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const ConstTensorHandle * m_OutputGateBias
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of LstmLayer.
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const ConstTensorHandle * m_CellLayerNormWeights
std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >> ConstantTensors
LstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
An LstmDescriptor for the LstmLayer.
#define ARMNN_ASSERT_MSG(COND, MSG)
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
bool m_PeepholeEnabled
Enable/disable peephole.
const ConstTensorHandle * m_CellToOutputWeights
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
#define ARMNN_ASSERT(COND)
LstmOptLayerNormParameters m_LayerNormParameters
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
const ConstTensorHandle * m_InputToCellWeights
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
const ConstTensorHandle * m_InputToForgetWeights
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size].
const ConstTensorHandle * m_RecurrentToInputWeights
Layer::ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
LstmOptPeepholeParameters m_PeepholeParameters
void SetAdditionalInfo(QueueDescriptor &descriptor) const
const ConstTensorHandle * m_ForgetGateBias
LstmOptProjectionParameters m_ProjectionParameters
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
const ConstTensorHandle * m_CellToForgetWeights
const ConstTensorHandle * m_ProjectionBias
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
LstmLayer(const LstmDescriptor ¶m, const char *name)
Constructor to create a LstmLayer.
bool m_LayerNormEnabled
Enable/disable layer normalization.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
const ConstTensorHandle * m_ForgetLayerNormWeights
virtual const TensorInfo & GetTensorInfo() const =0
LstmOptCifgParameters m_CifgParameters
const char * GetName() const override
Returns the name of the layer.
const ConstTensorHandle * m_InputLayerNormWeights
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
By default returns inputShapes if the number of inputs are equal to number of outputs, otherwise infers the output shapes from given input shapes and layer properties.
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
const ConstTensorHandle * m_CellToInputWeights
const TensorInfo & GetTensorInfo() const override
const ConstTensorHandle * m_InputToInputWeights
ShapeInferenceMethod m_ShapeInferenceMethod
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
const ConstTensorHandle * m_RecurrentToOutputWeights