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.");
342 managedInputToInputWeights.
Map());
343 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
350 managedInputToForgetWeights.
Map());
351 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
358 managedInputToCellWeights.
Map());
359 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
366 managedInputToOutputWeights.
Map());
367 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
375 managedRecurrentToInputWeights.
Map());
376 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
384 managedRecurrentToForgetWeights.
Map());
385 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
393 managedRecurrentToCellWeights.
Map());
394 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
402 managedRecurrentToOutputWeights.
Map());
403 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
410 managedCellToInputWeights.
Map());
411 cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
418 managedCellToForgetWeights.
Map());
419 cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
426 managedCellToOutputWeights.
Map());
427 cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
434 managedInputGateBias.
Map());
435 inputGateBiasTensor = inputGateBiasTensorCopy;
442 managedForgetGateBias.
Map());
443 forgetGateBiasTensor = forgetGateBiasTensorCopy;
450 managedCellBias.
Map());
451 cellBiasTensor = cellBiasTensorCopy;
458 managedOutputGateBias.
Map());
459 outputGateBias = outputGateBiasCopy;
466 managedProjectionWeights.
Map());
467 projectionWeightsTensor = projectionWeightsTensorCopy;
474 managedProjectionBias.
Map());
475 projectionBiasTensor = projectionBiasTensorCopy;
482 managedInputLayerNormWeights.
Map());
483 inputLayerNormTensor = inputLayerNormTensorCopy;
490 managedForgetLayerNormWeights.
Map());
491 forgetLayerNormTensor = forgetLayerNormTensorCopy;
498 managedCellLayerNormWeights.
Map());
499 cellLayerNormTensor = cellLayerNormTensorCopy;
506 managedOutputLayerNormWeights.
Map());
507 outputLayerNormTensor = outputLayerNormTensorCopy;
518 std::vector<ConstTensor> constTensors;
556 managedInputToForgetWeights.
Map()));
561 managedInputToCellWeights.
Map()));
566 managedInputToOutputWeights.
Map()));
572 managedRecurrentToForgetWeights.
Map()));
578 managedRecurrentToCellWeights.
Map()));
584 managedRecurrentToOutputWeights.
Map()));
589 managedForgetGateBias.
Map()));
594 managedCellBias.
Map()));
599 managedOutputGateBias.
Map()));
608 managedInputToInputWeights.
Map()));
614 managedRecurrentToInputWeights.
Map()));
619 managedInputGateBias.
Map()));
631 managedCellToInputWeights.
Map()));
637 managedCellToForgetWeights.
Map()));
642 managedCellToOutputWeights.
Map()));
652 managedProjectionWeights.
Map()));
657 managedProjectionBias.
Map()));
669 managedInputLayerNormWeights.
Map()));
675 managedForgetLayerNormWeights.
Map()));
680 managedCellLayerNormWeights.
Map()));
685 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 TensorShape & GetShape() const
ARMNN_NO_DEPRECATE_WARN_END void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
const ConstTensorHandle * m_InputGateBias
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
const ConstTensorHandle * m_RecurrentToCellWeights
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
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].
const LstmDescriptor & GetParameters() const override
This layer represents a LSTM operation.
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_NO_DEPRECATE_WARN_END
#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
ARMNN_NO_DEPRECATE_WARN_BEGIN void Accept(ILayerVisitor &visitor) const override
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).
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
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const
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