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)
137 if (!m_Param.m_CifgEnabled) {
150 return std::move(layer);
158 unsigned int batchSize = inputShapes[0][0];
159 unsigned int outputSize = inputShapes[1][1];
160 unsigned int numUnits = inputShapes[2][1];
162 std::vector<TensorShape> outShapes;
163 outShapes.push_back(
TensorShape({ batchSize, outputSize }));
164 outShapes.push_back(
TensorShape({ batchSize, numUnits }));
165 outShapes.push_back(
TensorShape({ batchSize, outputSize }));
189 "QLstmLayer: m_BasicParameters.m_InputToForgetWeights should not be null.");
191 "QLstmLayer: m_BasicParameters.m_InputToCellWeights should not be null.");
193 "QLstmLayer: m_BasicParameters.m_InputToOutputWeights should not be null.");
195 "QLstmLayer: m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
197 "QLstmLayer: m_BasicParameters.m_RecurrentToCellWeights should not be null.");
199 "QLstmLayer: m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
201 "QLstmLayer: m_BasicParameters.m_ForgetGateBias should not be null.");
203 "QLstmLayer: m_BasicParameters.m_CellBias should not be null.");
205 "QLstmLayer: m_BasicParameters.m_OutputGateBias should not be null.");
210 "QLstmLayer: m_CifgParameters.m_InputToInputWeights should not be null.");
212 "QLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not be null.");
214 "QLstmLayer: m_CifgParameters.m_InputGateBias should not be null.");
221 "QLstmLayer: m_CifgParameters.m_InputToInputWeights should not have a value when CIFG is enabled.");
223 "QLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should " 224 "not have a value when CIFG is enabled.");
226 "QLstmLayer: m_CifgParameters.m_InputGateBias should not have a value when CIFG is enabled.");
234 "QLstmLayer: m_ProjectionParameters.m_ProjectionWeights should not be null.");
241 "QLstmLayer: m_PeepholeParameters.m_CellToInputWeights should not be null " 242 "when Peephole is enabled and CIFG is disabled.");
246 "QLstmLayer: m_PeepholeParameters.m_CellToForgetWeights should not be null.");
248 "QLstmLayer: m_PeepholeParameters.m_CellToOutputWeights should not be null.");
261 "QLstmLayer: m_LayerNormParameters.m_InputLayerNormWeights should not be null.");
264 "QLstmLayer: m_LayerNormParameters.m_ForgetLayerNormWeights should not be null.");
266 "QLstmLayer: m_LayerNormParameters.m_CellLayerNormWeights should not be null.");
268 "QLstmLayer: m_LayerNormParameters.m_UutputLayerNormWeights should not be null.");
342 managedInputToInputWeights.
Map());
343 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
351 managedInputToForgetWeights.
Map());
352 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
360 managedInputToCellWeights.
Map());
361 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
369 managedInputToOutputWeights.
Map());
370 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
379 managedRecurrentToInputWeights.
Map());
380 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
389 managedRecurrentToForgetWeights.
Map());
390 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
399 managedRecurrentToCellWeights.
Map());
400 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
409 managedRecurrentToOutputWeights.
Map());
410 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
418 managedCellToInputWeights.
Map());
419 cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
427 managedCellToForgetWeights.
Map());
428 cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
436 managedCellToOutputWeights.
Map());
437 cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
445 managedInputGateBias.
Map());
446 inputGateBiasTensor = inputGateBiasTensorCopy;
454 managedForgetGateBias.
Map());
455 forgetGateBiasTensor = forgetGateBiasTensorCopy;
463 managedCellBias.
Map());
464 cellBiasTensor = cellBiasTensorCopy;
472 managedOutputGateBias.
Map());
473 outputGateBias = outputGateBiasCopy;
481 managedProjectionWeights.
Map());
482 projectionWeightsTensor = projectionWeightsTensorCopy;
490 managedProjectionBias.
Map());
491 projectionBiasTensor = projectionBiasTensorCopy;
499 managedInputLayerNormWeights.
Map());
500 inputLayerNormTensor = inputLayerNormTensorCopy;
508 managedForgetLayerNormWeights.
Map());
509 forgetLayerNormTensor = forgetLayerNormTensorCopy;
517 managedCellLayerNormWeights.
Map());
518 cellLayerNormTensor = cellLayerNormTensorCopy;
526 managedOutputLayerNormWeights.
Map());
527 outputLayerNormTensor = outputLayerNormTensorCopy;
538 std::vector<ConstTensor> constTensors;
573 managedInputToForgetWeights.
Map()));
578 managedInputToCellWeights.
Map()));
583 managedInputToOutputWeights.
Map()));
589 managedRecurrentToForgetWeights.
Map()));
595 managedRecurrentToCellWeights.
Map()));
601 managedRecurrentToOutputWeights.
Map()));
606 managedForgetGateBias.
Map()));
611 managedCellBias.
Map()));
616 managedOutputGateBias.
Map()));
623 managedInputToInputWeights.
Map()));
629 managedRecurrentToInputWeights.
Map()));
634 managedInputGateBias.
Map()));
641 managedCellToInputWeights.
Map()));
646 managedCellToForgetWeights.
Map()));
651 managedCellToOutputWeights.
Map()));
658 managedProjectionWeights.
Map()));
663 managedProjectionBias.
Map()));
670 managedInputLayerNormWeights.
Map()));
675 managedForgetLayerNormWeights.
Map()));
680 managedCellLayerNormWeights.
Map()));
685 managedOutputLayerNormWeights.
Map()));
const ConstTensorHandle * m_CellLayerNormWeights
const ConstTensorHandle * m_ProjectionWeights
virtual void VisitQLstmLayer(const IConnectableLayer *layer, const QLstmDescriptor &descriptor, const LstmInputParams ¶ms, const char *name=nullptr)=0
Function a QLstm layer should call back to when its Accept(ILayerVisitor&) function is invoked...
const ConstTensorHandle * m_ForgetGateBias
const ConstTensorHandle * m_InputToOutputWeights
QLstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const QLstmDescriptor & GetParameters() const
const TensorShape & GetShape() const
QLstmOptProjectionParameters m_ProjectionParameters
std::shared_ptr< ConstTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
bool m_PeepholeEnabled
Enable/disable peephole.
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
const ConstTensorHandle * m_InputToInputWeights
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
const ConstTensorHandle * m_CellToOutputWeights
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
const ConstTensorHandle * m_CellToInputWeights
virtual std::unique_ptr< IWorkload > CreateQLstm(const QLstmQueueDescriptor &descriptor, const WorkloadInfo &info) const
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
const TensorInfo & GetTensorInfo() const
Copyright (c) 2021 ARM Limited and Contributors.
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
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_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
QLstmOptLayerNormParameters m_LayerNormParameters
QLstmLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
const ConstTensorHandle * m_ForgetLayerNormWeights
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8)...
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
bool m_LayerNormEnabled
Enable/disable layer normalization.
std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >> ConstantTensors
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
#define ARMNN_ASSERT_MSG(COND, MSG)
std::shared_ptr< ConstTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the QLstm type.
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
const ConstTensorHandle * m_InputToForgetWeights
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
const ConstTensorHandle * m_CellBias
#define ARMNN_ASSERT(COND)
A QLstmDescriptor for the QLstmLayer.
const ConstTensorHandle * m_InputLayerNormWeights
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of QLstmLayer.
QLstmLayer(const QLstmDescriptor ¶m, const char *name)
Constructor to create a QLstmLayer.
Layer::ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
std::shared_ptr< ConstTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
QLstmBasicParameters m_BasicParameters
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
const ConstTensorHandle * m_InputToCellWeights
void SetAdditionalInfo(QueueDescriptor &descriptor) const
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
This layer represents a QLstm operation.
const ConstTensorHandle * m_CellToForgetWeights
const ConstTensorHandle * m_ProjectionBias
const ConstTensorHandle * m_RecurrentToCellWeights
bool m_ProjectionEnabled
Enable/disable the projection layer.
const ConstTensorHandle * m_InputGateBias
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
virtual const TensorInfo & GetTensorInfo() const =0
QLstmOptCifgParameters m_CifgParameters
QLstmOptPeepholeParameters m_PeepholeParameters
const char * GetName() const override
Returns the name of the layer.
const ConstTensorHandle * m_OutputGateBias
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
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_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
const ConstTensorHandle * m_OutputLayerNormWeights
const TensorInfo & GetTensorInfo() const override
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_RecurrentToInputWeights
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
ShapeInferenceMethod m_ShapeInferenceMethod
const ConstTensorHandle * m_RecurrentToForgetWeights
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...