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.");
343 managedInputToInputWeights.
Map());
344 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
352 managedInputToForgetWeights.
Map());
353 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
361 managedInputToCellWeights.
Map());
362 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
370 managedInputToOutputWeights.
Map());
371 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
380 managedRecurrentToInputWeights.
Map());
381 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
390 managedRecurrentToForgetWeights.
Map());
391 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
400 managedRecurrentToCellWeights.
Map());
401 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
410 managedRecurrentToOutputWeights.
Map());
411 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
419 managedCellToInputWeights.
Map());
420 cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
428 managedCellToForgetWeights.
Map());
429 cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
437 managedCellToOutputWeights.
Map());
438 cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
446 managedInputGateBias.
Map());
447 inputGateBiasTensor = inputGateBiasTensorCopy;
455 managedForgetGateBias.
Map());
456 forgetGateBiasTensor = forgetGateBiasTensorCopy;
464 managedCellBias.
Map());
465 cellBiasTensor = cellBiasTensorCopy;
473 managedOutputGateBias.
Map());
474 outputGateBias = outputGateBiasCopy;
482 managedProjectionWeights.
Map());
483 projectionWeightsTensor = projectionWeightsTensorCopy;
491 managedProjectionBias.
Map());
492 projectionBiasTensor = projectionBiasTensorCopy;
500 managedInputLayerNormWeights.
Map());
501 inputLayerNormTensor = inputLayerNormTensorCopy;
509 managedForgetLayerNormWeights.
Map());
510 forgetLayerNormTensor = forgetLayerNormTensorCopy;
518 managedCellLayerNormWeights.
Map());
519 cellLayerNormTensor = cellLayerNormTensorCopy;
527 managedOutputLayerNormWeights.
Map());
528 outputLayerNormTensor = outputLayerNormTensorCopy;
540 std::vector<ConstTensor> constTensors;
575 managedInputToForgetWeights.
Map()));
580 managedInputToCellWeights.
Map()));
585 managedInputToOutputWeights.
Map()));
591 managedRecurrentToForgetWeights.
Map()));
597 managedRecurrentToCellWeights.
Map()));
603 managedRecurrentToOutputWeights.
Map()));
608 managedForgetGateBias.
Map()));
613 managedCellBias.
Map()));
618 managedOutputGateBias.
Map()));
625 managedInputToInputWeights.
Map()));
631 managedRecurrentToInputWeights.
Map()));
636 managedInputGateBias.
Map()));
643 managedCellToInputWeights.
Map()));
648 managedCellToForgetWeights.
Map()));
653 managedCellToOutputWeights.
Map()));
660 managedProjectionWeights.
Map()));
665 managedProjectionBias.
Map()));
672 managedInputLayerNormWeights.
Map()));
677 managedForgetLayerNormWeights.
Map()));
682 managedCellLayerNormWeights.
Map()));
687 managedOutputLayerNormWeights.
Map()));
const ConstTensorHandle * m_CellLayerNormWeights
const ConstTensorHandle * m_ProjectionWeights
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). ...
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
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
#define ARMNN_NO_DEPRECATE_WARN_END
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
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
ARMNN_NO_DEPRECATE_WARN_BEGIN void Accept(ILayerVisitor &visitor) const override
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.
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
ARMNN_NO_DEPRECATE_WARN_END void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
const ConstTensorHandle * m_RecurrentToForgetWeights
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...