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.");
344 managedInputToInputWeights.
Map());
345 inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
353 managedInputToForgetWeights.
Map());
354 inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
362 managedInputToCellWeights.
Map());
363 inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
371 managedInputToOutputWeights.
Map());
372 inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
381 managedRecurrentToInputWeights.
Map());
382 recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
391 managedRecurrentToForgetWeights.
Map());
392 recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
401 managedRecurrentToCellWeights.
Map());
402 recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
411 managedRecurrentToOutputWeights.
Map());
412 recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
420 managedCellToInputWeights.
Map());
421 cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
429 managedCellToForgetWeights.
Map());
430 cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
438 managedCellToOutputWeights.
Map());
439 cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
447 managedInputGateBias.
Map());
448 inputGateBiasTensor = inputGateBiasTensorCopy;
456 managedForgetGateBias.
Map());
457 forgetGateBiasTensor = forgetGateBiasTensorCopy;
465 managedCellBias.
Map());
466 cellBiasTensor = cellBiasTensorCopy;
474 managedOutputGateBias.
Map());
475 outputGateBias = outputGateBiasCopy;
483 managedProjectionWeights.
Map());
484 projectionWeightsTensor = projectionWeightsTensorCopy;
492 managedProjectionBias.
Map());
493 projectionBiasTensor = projectionBiasTensorCopy;
501 managedInputLayerNormWeights.
Map());
502 inputLayerNormTensor = inputLayerNormTensorCopy;
510 managedForgetLayerNormWeights.
Map());
511 forgetLayerNormTensor = forgetLayerNormTensorCopy;
519 managedCellLayerNormWeights.
Map());
520 cellLayerNormTensor = cellLayerNormTensorCopy;
528 managedOutputLayerNormWeights.
Map());
529 outputLayerNormTensor = outputLayerNormTensorCopy;
541 std::vector<ConstTensor> constTensors;
576 managedInputToForgetWeights.
Map()));
581 managedInputToCellWeights.
Map()));
586 managedInputToOutputWeights.
Map()));
592 managedRecurrentToForgetWeights.
Map()));
598 managedRecurrentToCellWeights.
Map()));
604 managedRecurrentToOutputWeights.
Map()));
609 managedForgetGateBias.
Map()));
614 managedCellBias.
Map()));
619 managedOutputGateBias.
Map()));
626 managedInputToInputWeights.
Map()));
632 managedRecurrentToInputWeights.
Map()));
637 managedInputGateBias.
Map()));
644 managedCellToInputWeights.
Map()));
649 managedCellToForgetWeights.
Map()));
654 managedCellToOutputWeights.
Map()));
661 managedProjectionWeights.
Map()));
666 managedProjectionBias.
Map()));
673 managedInputLayerNormWeights.
Map()));
678 managedForgetLayerNormWeights.
Map()));
683 managedCellLayerNormWeights.
Map()));
688 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 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
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.
const QLstmDescriptor & GetParameters() const override
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
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const
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...