ArmNN
 26.01
Loading...
Searching...
No Matches
QLstmLayer Class Reference

This layer represents a QLstm operation. More...

#include <QLstmLayer.hpp>

Inheritance diagram for QLstmLayer:
[legend]
Collaboration diagram for QLstmLayer:
[legend]

Public Member Functions

virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const override
 Makes a workload for the QLstm type.
 
QLstmLayerClone (Graph &graph) const override
 Creates a dynamically-allocated copy of this layer.
 
void ValidateTensorShapesFromInputs () override
 Check if the input tensor shape(s) will lead to a valid configuration of QLstmLayer.
 
std::vector< TensorShapeInferOutputShapes (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.
 
void ExecuteStrategy (IStrategy &strategy) const override
 Apply a visitor to this layer.
 
- Public Member Functions inherited from LayerWithParameters< QLstmDescriptor >
const QLstmDescriptorGetParameters () const override
 If the layer has a descriptor return it.
 
void SerializeLayerParameters (ParameterStringifyFunction &fn) const override
 Helper to serialize the layer parameters to string (currently used in DotSerializer and company).
 
- Public Member Functions inherited from Layer
 Layer (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
 
 Layer (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, DataLayout layout, const char *name)
 
const std::string & GetNameStr () const
 
const OutputHandlerGetOutputHandler (unsigned int i=0) const
 
OutputHandlerGetOutputHandler (unsigned int i=0)
 
ShapeInferenceMethod GetShapeInferenceMethod () const
 
bool GetAllowExpandedDims () const
 
const std::vector< InputSlot > & GetInputSlots () const
 
const std::vector< OutputSlot > & GetOutputSlots () const
 
std::vector< InputSlot >::iterator BeginInputSlots ()
 
std::vector< InputSlot >::iterator EndInputSlots ()
 
std::vector< OutputSlot >::iterator BeginOutputSlots ()
 
std::vector< OutputSlot >::iterator EndOutputSlots ()
 
bool IsOutputUnconnected ()
 
void ResetPriority () const
 
LayerPriority GetPriority () const
 
LayerType GetType () const override
 Returns the armnn::LayerType of this layer.
 
DataType GetDataType () const
 
const BackendIdGetBackendId () const
 
void SetBackendId (const BackendId &id) override
 Set the backend of the IConnectableLayer.
 
virtual void CreateTensorHandles (const TensorHandleFactoryRegistry &registry, const IWorkloadFactory &factory, const bool IsMemoryManaged=true)
 
void VerifyLayerConnections (unsigned int expectedConnections, const CheckLocation &location) const
 
virtual void ReleaseConstantData ()
 
template<typename Op >
void OperateOnConstantTensors (Op op)
 
const char * GetName () const override
 Returns the name of the layer.
 
unsigned int GetNumInputSlots () const override
 Returns the number of connectable input slots.
 
unsigned int GetNumOutputSlots () const override
 Returns the number of connectable output slots.
 
const InputSlotGetInputSlot (unsigned int index) const override
 Get a const input slot handle by slot index.
 
InputSlotGetInputSlot (unsigned int index) override
 Get the input slot handle by slot index.
 
const OutputSlotGetOutputSlot (unsigned int index=0) const override
 Get the const output slot handle by slot index.
 
OutputSlotGetOutputSlot (unsigned int index=0) override
 Get the output slot handle by slot index.
 
void SetGuid (LayerGuid guid)
 
LayerGuid GetGuid () const final
 Returns the unique id of the layer.
 
void AddRelatedLayerName (const std::string layerName)
 
const std::list< std::string > & GetRelatedLayerNames ()
 
virtual void Reparent (Graph &dest, std::list< Layer * >::const_iterator iterator)=0
 
void BackendSelectionHint (Optional< BackendId > backend) final
 Provide a hint for the optimizer as to which backend to prefer for this layer.
 
Optional< BackendIdGetBackendHint () const
 
void SetShapeInferenceMethod (ShapeInferenceMethod shapeInferenceMethod)
 
void SetAllowExpandedDims (bool allowExpandedDims)
 
template<typename T >
std::shared_ptr< T > GetAdditionalInformation () const
 
void SetAdditionalInfoForObject (const AdditionalInfoObjectPtr &additionalInfo)
 

Public Attributes

QLstmBasicParameters m_BasicParameters
 
QLstmOptCifgParameters m_CifgParameters
 
QLstmOptProjectionParameters m_ProjectionParameters
 
QLstmOptPeepholeParameters m_PeepholeParameters
 
QLstmOptLayerNormParameters m_LayerNormParameters
 

Protected Member Functions

 QLstmLayer (const QLstmDescriptor &param, const char *name)
 Constructor to create a QLstmLayer.
 
 ~QLstmLayer ()=default
 Default destructor.
 
Layer::ImmutableConstantTensors GetConstantTensorsByRef () const override
 Retrieve the handles to the constant values stored by the layer.
 
- Protected Member Functions inherited from LayerWithParameters< QLstmDescriptor >
 LayerWithParameters (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const QLstmDescriptor &param, const char *name)
 
 ~LayerWithParameters ()=default
 
WorkloadInfo PrepInfoAndDesc (QueueDescriptor &descriptor) const
 Helper function to reduce duplication in *LayerCreateWorkload.
 
Layer::ImmutableConstantTensors GetConnectedConstantAsInputTensors () const
 
- Protected Member Functions inherited from Layer
virtual ~Layer ()=default
 
template<typename QueueDescriptor >
void CollectQueueDescriptorInputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
template<typename QueueDescriptor >
void CollectQueueDescriptorOutputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
void ValidateAndCopyShape (const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
 
void VerifyShapeInferenceType (const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
 
template<typename QueueDescriptor >
WorkloadInfo PrepInfoAndDesc (QueueDescriptor &descriptor) const
 Helper function to reduce duplication in *LayerCreateWorkload.
 
template<typename LayerType , typename ... Params>
LayerTypeCloneBase (Graph &graph, Params &&... params) const
 
virtual ConstantTensors GetConstantTensorsByRef () override final
 
void SetAdditionalInfo (QueueDescriptor &descriptor) const
 
- Protected Member Functions inherited from IConnectableLayer
 ~IConnectableLayer ()
 Objects are not deletable via the handle.
 

Additional Inherited Members

- Public Types inherited from LayerWithParameters< QLstmDescriptor >
using DescriptorType
 
- Public Types inherited from IConnectableLayer
using ConstantTensors = std::vector<std::reference_wrapper<std::shared_ptr<ConstTensorHandle>>>
 
using ImmutableConstantTensors = std::vector<std::reference_wrapper<const std::shared_ptr<ConstTensorHandle>>>
 
- Protected Attributes inherited from LayerWithParameters< QLstmDescriptor >
QLstmDescriptor m_Param
 The parameters for the layer (not including tensor-valued weights etc.).
 
- Protected Attributes inherited from Layer
AdditionalInfoObjectPtr m_AdditionalInfoObject
 
std::vector< OutputHandlerm_OutputHandlers
 
ShapeInferenceMethod m_ShapeInferenceMethod
 

Detailed Description

This layer represents a QLstm operation.

Definition at line 79 of file QLstmLayer.hpp.

Constructor & Destructor Documentation

◆ QLstmLayer()

QLstmLayer ( const QLstmDescriptor & param,
const char * name )
protected

Constructor to create a QLstmLayer.

Parameters
[in]nameOptional name for the layer.

Definition at line 17 of file QLstmLayer.cpp.

18 : LayerWithParameters(3, 3, LayerType::QLstm, param, name)
19{
20}
LayerWithParameters(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const QLstmDescriptor &param, const char *name)

◆ ~QLstmLayer()

~QLstmLayer ( )
protecteddefault

Default destructor.

Member Function Documentation

◆ Clone()

QLstmLayer * Clone ( Graph & graph) const
overridevirtual

Creates a dynamically-allocated copy of this layer.

Parameters
[in]graphThe graph into which this layer is being cloned.

Implements Layer.

Definition at line 81 of file QLstmLayer.cpp.

82{
83 auto layer = CloneBase<QLstmLayer>(graph, m_Param, GetName());
84
85 layer->m_BasicParameters.m_InputToForgetWeights = m_BasicParameters.m_InputToForgetWeights ?
87 layer->m_BasicParameters.m_InputToCellWeights = m_BasicParameters.m_InputToCellWeights ?
89 layer->m_BasicParameters.m_InputToOutputWeights = m_BasicParameters.m_InputToOutputWeights ?
91 layer->m_BasicParameters.m_RecurrentToForgetWeights = m_BasicParameters.m_RecurrentToForgetWeights ?
93 layer->m_BasicParameters.m_RecurrentToCellWeights = m_BasicParameters.m_RecurrentToCellWeights ?
95 layer->m_BasicParameters.m_RecurrentToOutputWeights = m_BasicParameters.m_RecurrentToOutputWeights ?
97 layer->m_BasicParameters.m_ForgetGateBias = m_BasicParameters.m_ForgetGateBias ?
99 layer->m_BasicParameters.m_CellBias = m_BasicParameters.m_CellBias ?
101 layer->m_BasicParameters.m_OutputGateBias = m_BasicParameters.m_OutputGateBias ?
103
105 {
106 layer->m_CifgParameters.m_InputToInputWeights = m_CifgParameters.m_InputToInputWeights ?
108 layer->m_CifgParameters.m_RecurrentToInputWeights = m_CifgParameters.m_RecurrentToInputWeights ?
110 layer->m_CifgParameters.m_InputGateBias = m_CifgParameters.m_InputGateBias ?
112 }
113
115 {
116 layer->m_ProjectionParameters.m_ProjectionWeights = m_ProjectionParameters.m_ProjectionWeights ?
118 layer->m_ProjectionParameters.m_ProjectionBias = m_ProjectionParameters.m_ProjectionBias ?
120 }
121
123 {
124 if (!m_Param.m_CifgEnabled) {
125 layer->m_PeepholeParameters.m_CellToInputWeights = m_PeepholeParameters.m_CellToInputWeights ?
127 }
128
129 layer->m_PeepholeParameters.m_CellToForgetWeights = m_PeepholeParameters.m_CellToForgetWeights ?
131 layer->m_PeepholeParameters.m_CellToOutputWeights = m_PeepholeParameters.m_CellToOutputWeights ?
133 }
134
136 {
137 if (!m_Param.m_CifgEnabled) {
138 layer->m_LayerNormParameters.m_InputLayerNormWeights = m_LayerNormParameters.m_InputLayerNormWeights ?
140 }
141
142 layer->m_LayerNormParameters.m_ForgetLayerNormWeights = m_LayerNormParameters.m_ForgetLayerNormWeights ?
144 layer->m_LayerNormParameters.m_CellLayerNormWeights = m_LayerNormParameters.m_CellLayerNormWeights ?
146 layer->m_LayerNormParameters.m_OutputLayerNormWeights = m_LayerNormParameters.m_OutputLayerNormWeights ?
148 }
149
150 return std::move(layer);
151}
const char * GetName() const override
Returns the name of the layer.
Definition Layer.hpp:332
QLstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
QLstmOptProjectionParameters m_ProjectionParameters
QLstmOptPeepholeParameters m_PeepholeParameters
QLstmBasicParameters m_BasicParameters
QLstmOptLayerNormParameters m_LayerNormParameters
QLstmOptCifgParameters m_CifgParameters
std::shared_ptr< ConstTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
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_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32).
bool m_PeepholeEnabled
Enable/disable peephole.
bool m_LayerNormEnabled
Enable/disable layer normalization.
bool m_ProjectionEnabled
Enable/disable the projection layer.
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8).
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
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).
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8).

References Layer::GetName(), QLstmLayer::m_BasicParameters, QLstmBasicParameters::m_CellBias, QLstmOptLayerNormParameters::m_CellLayerNormWeights, QLstmOptPeepholeParameters::m_CellToForgetWeights, QLstmOptPeepholeParameters::m_CellToInputWeights, QLstmOptPeepholeParameters::m_CellToOutputWeights, QLstmDescriptor::m_CifgEnabled, QLstmLayer::m_CifgParameters, QLstmBasicParameters::m_ForgetGateBias, QLstmOptLayerNormParameters::m_ForgetLayerNormWeights, QLstmOptCifgParameters::m_InputGateBias, QLstmOptLayerNormParameters::m_InputLayerNormWeights, QLstmBasicParameters::m_InputToCellWeights, QLstmBasicParameters::m_InputToForgetWeights, QLstmOptCifgParameters::m_InputToInputWeights, QLstmBasicParameters::m_InputToOutputWeights, QLstmDescriptor::m_LayerNormEnabled, QLstmLayer::m_LayerNormParameters, QLstmBasicParameters::m_OutputGateBias, QLstmOptLayerNormParameters::m_OutputLayerNormWeights, LayerWithParameters< QLstmDescriptor >::m_Param, QLstmDescriptor::m_PeepholeEnabled, QLstmLayer::m_PeepholeParameters, QLstmOptProjectionParameters::m_ProjectionBias, QLstmDescriptor::m_ProjectionEnabled, QLstmLayer::m_ProjectionParameters, QLstmOptProjectionParameters::m_ProjectionWeights, QLstmBasicParameters::m_RecurrentToCellWeights, QLstmBasicParameters::m_RecurrentToForgetWeights, QLstmOptCifgParameters::m_RecurrentToInputWeights, and QLstmBasicParameters::m_RecurrentToOutputWeights.

◆ CreateWorkload()

std::unique_ptr< IWorkload > CreateWorkload ( const IWorkloadFactory & factory) const
overridevirtual

Makes a workload for the QLstm type.

Parameters
[in]graphThe graph where this layer can be found.
[in]factoryThe workload factory which will create the workload.
Returns
A pointer to the created workload, or nullptr if not created.

Implements Layer.

Definition at line 22 of file QLstmLayer.cpp.

23{
24 QLstmQueueDescriptor descriptor;
25
26 // Basic parameters
27 descriptor.m_InputToForgetWeights = m_BasicParameters.m_InputToForgetWeights.get();
28 descriptor.m_InputToCellWeights = m_BasicParameters.m_InputToCellWeights.get();
29 descriptor.m_InputToOutputWeights = m_BasicParameters.m_InputToOutputWeights.get();
30 descriptor.m_RecurrentToForgetWeights = m_BasicParameters.m_RecurrentToForgetWeights.get();
31 descriptor.m_RecurrentToCellWeights = m_BasicParameters.m_RecurrentToCellWeights.get();
32 descriptor.m_RecurrentToOutputWeights = m_BasicParameters.m_RecurrentToOutputWeights.get();
33 descriptor.m_ForgetGateBias = m_BasicParameters.m_ForgetGateBias.get();
34 descriptor.m_CellBias = m_BasicParameters.m_CellBias.get();
35 descriptor.m_OutputGateBias = m_BasicParameters.m_OutputGateBias.get();
36
37 // CIFG parameters
39 {
40 descriptor.m_InputToInputWeights = m_CifgParameters.m_InputToInputWeights.get();
41 descriptor.m_RecurrentToInputWeights = m_CifgParameters.m_RecurrentToInputWeights.get();
42 descriptor.m_InputGateBias = m_CifgParameters.m_InputGateBias.get();
43 }
44
45 // Projection parameters
47 {
48 descriptor.m_ProjectionWeights = m_ProjectionParameters.m_ProjectionWeights.get();
49 descriptor.m_ProjectionBias = m_ProjectionParameters.m_ProjectionBias.get();
50 }
51
52 // Peephole parameters
54 {
56 {
57 descriptor.m_CellToInputWeights = m_PeepholeParameters.m_CellToInputWeights.get();
58 }
59
60 descriptor.m_CellToForgetWeights = m_PeepholeParameters.m_CellToForgetWeights.get();
61 descriptor.m_CellToOutputWeights = m_PeepholeParameters.m_CellToOutputWeights.get();
62 }
63
64 // Layer normalisation parameters
66 {
68 {
69 descriptor.m_InputLayerNormWeights = m_LayerNormParameters.m_InputLayerNormWeights.get();
70 }
71 descriptor.m_ForgetLayerNormWeights = m_LayerNormParameters.m_ForgetLayerNormWeights.get();
72 descriptor.m_CellLayerNormWeights = m_LayerNormParameters.m_CellLayerNormWeights.get();
73 descriptor.m_OutputLayerNormWeights = m_LayerNormParameters.m_OutputLayerNormWeights.get();
74 }
75
76 SetAdditionalInfo(descriptor);
77
78 return factory.CreateWorkload(LayerType::QLstm, descriptor, PrepInfoAndDesc(descriptor));
79}
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition Layer.cpp:303
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.

References IWorkloadFactory::CreateWorkload(), QLstmLayer::m_BasicParameters, QLstmQueueDescriptor::m_CellBias, QLstmBasicParameters::m_CellBias, QLstmQueueDescriptor::m_CellLayerNormWeights, QLstmOptLayerNormParameters::m_CellLayerNormWeights, QLstmQueueDescriptor::m_CellToForgetWeights, QLstmOptPeepholeParameters::m_CellToForgetWeights, QLstmQueueDescriptor::m_CellToInputWeights, QLstmOptPeepholeParameters::m_CellToInputWeights, QLstmQueueDescriptor::m_CellToOutputWeights, QLstmOptPeepholeParameters::m_CellToOutputWeights, QLstmDescriptor::m_CifgEnabled, QLstmLayer::m_CifgParameters, QLstmQueueDescriptor::m_ForgetGateBias, QLstmBasicParameters::m_ForgetGateBias, QLstmQueueDescriptor::m_ForgetLayerNormWeights, QLstmOptLayerNormParameters::m_ForgetLayerNormWeights, QLstmQueueDescriptor::m_InputGateBias, QLstmOptCifgParameters::m_InputGateBias, QLstmQueueDescriptor::m_InputLayerNormWeights, QLstmOptLayerNormParameters::m_InputLayerNormWeights, QLstmQueueDescriptor::m_InputToCellWeights, QLstmBasicParameters::m_InputToCellWeights, QLstmQueueDescriptor::m_InputToForgetWeights, QLstmBasicParameters::m_InputToForgetWeights, QLstmQueueDescriptor::m_InputToInputWeights, QLstmOptCifgParameters::m_InputToInputWeights, QLstmQueueDescriptor::m_InputToOutputWeights, QLstmBasicParameters::m_InputToOutputWeights, QLstmDescriptor::m_LayerNormEnabled, QLstmLayer::m_LayerNormParameters, QLstmQueueDescriptor::m_OutputGateBias, QLstmBasicParameters::m_OutputGateBias, QLstmQueueDescriptor::m_OutputLayerNormWeights, QLstmOptLayerNormParameters::m_OutputLayerNormWeights, LayerWithParameters< QLstmDescriptor >::m_Param, QLstmDescriptor::m_PeepholeEnabled, QLstmLayer::m_PeepholeParameters, QLstmQueueDescriptor::m_ProjectionBias, QLstmOptProjectionParameters::m_ProjectionBias, QLstmDescriptor::m_ProjectionEnabled, QLstmLayer::m_ProjectionParameters, QLstmQueueDescriptor::m_ProjectionWeights, QLstmOptProjectionParameters::m_ProjectionWeights, QLstmQueueDescriptor::m_RecurrentToCellWeights, QLstmBasicParameters::m_RecurrentToCellWeights, QLstmQueueDescriptor::m_RecurrentToForgetWeights, QLstmBasicParameters::m_RecurrentToForgetWeights, QLstmQueueDescriptor::m_RecurrentToInputWeights, QLstmOptCifgParameters::m_RecurrentToInputWeights, QLstmQueueDescriptor::m_RecurrentToOutputWeights, QLstmBasicParameters::m_RecurrentToOutputWeights, LayerWithParameters< QLstmDescriptor >::PrepInfoAndDesc(), armnn::QLstm, and Layer::SetAdditionalInfo().

◆ ExecuteStrategy()

void ExecuteStrategy ( IStrategy & strategy) const
overridevirtual

Apply a visitor to this layer.

Reimplemented from LayerWithParameters< QLstmDescriptor >.

Definition at line 403 of file QLstmLayer.cpp.

404{
405 std::vector<ConstTensor> constTensors;
406 ManagedConstTensorHandle managedInputToForgetWeights(m_BasicParameters.m_InputToForgetWeights);
407 ManagedConstTensorHandle managedInputToCellWeights(m_BasicParameters.m_InputToCellWeights);
408 ManagedConstTensorHandle managedInputToOutputWeights(m_BasicParameters.m_InputToOutputWeights);
409 ManagedConstTensorHandle managedRecurrentToForgetWeights(m_BasicParameters.m_RecurrentToForgetWeights);
410 ManagedConstTensorHandle managedRecurrentToCellWeights(m_BasicParameters.m_RecurrentToCellWeights);
411 ManagedConstTensorHandle managedRecurrentToOutputWeights(m_BasicParameters.m_RecurrentToOutputWeights);
412 ManagedConstTensorHandle managedForgetGateBias(m_BasicParameters.m_ForgetGateBias);
413 ManagedConstTensorHandle managedCellBias(m_BasicParameters.m_CellBias);
414 ManagedConstTensorHandle managedOutputGateBias(m_BasicParameters.m_OutputGateBias);
415
416 // Cifg parameters
417 ManagedConstTensorHandle managedInputToInputWeights(m_CifgParameters.m_InputToInputWeights);
418 ManagedConstTensorHandle managedRecurrentToInputWeights(m_CifgParameters.m_RecurrentToInputWeights);
419 ManagedConstTensorHandle managedInputGateBias(m_CifgParameters.m_InputGateBias);
420
421 // Projection parameters
422 ManagedConstTensorHandle managedProjectionWeights(m_ProjectionParameters.m_ProjectionWeights);
423 ManagedConstTensorHandle managedProjectionBias(m_ProjectionParameters.m_ProjectionBias);
424
425 // Peephole parameters
426 ManagedConstTensorHandle managedCellToInputWeights(m_PeepholeParameters.m_CellToInputWeights);
427 ManagedConstTensorHandle managedCellToForgetWeights(m_PeepholeParameters.m_CellToForgetWeights);
428 ManagedConstTensorHandle managedCellToOutputWeights(m_PeepholeParameters.m_CellToOutputWeights);
429
430 // Layer normalisation parameters
431 ManagedConstTensorHandle managedInputLayerNormWeights(m_LayerNormParameters.m_InputLayerNormWeights);
432 ManagedConstTensorHandle managedForgetLayerNormWeights(m_LayerNormParameters.m_ForgetLayerNormWeights);
433 ManagedConstTensorHandle managedCellLayerNormWeights(m_LayerNormParameters.m_CellLayerNormWeights);
434 ManagedConstTensorHandle managedOutputLayerNormWeights(m_LayerNormParameters.m_OutputLayerNormWeights);
435
436 // First add mandatory/basic parameters
438 {
439 constTensors.emplace_back(ConstTensor(managedInputToForgetWeights.GetTensorInfo(),
440 managedInputToForgetWeights.Map()));
441 }
443 {
444 constTensors.emplace_back(ConstTensor(managedInputToCellWeights.GetTensorInfo(),
445 managedInputToCellWeights.Map()));
446 }
448 {
449 constTensors.emplace_back(ConstTensor(managedInputToOutputWeights.GetTensorInfo(),
450 managedInputToOutputWeights.Map()));
451 }
453 {
454 constTensors.emplace_back(ConstTensor(
455 managedRecurrentToForgetWeights.GetTensorInfo(),
456 managedRecurrentToForgetWeights.Map()));
457 }
459 {
460 constTensors.emplace_back(ConstTensor(
461 managedRecurrentToCellWeights.GetTensorInfo(),
462 managedRecurrentToCellWeights.Map()));
463 }
465 {
466 constTensors.emplace_back(ConstTensor(
467 managedRecurrentToOutputWeights.GetTensorInfo(),
468 managedRecurrentToOutputWeights.Map()));
469 }
470 if (m_BasicParameters.m_ForgetGateBias != nullptr)
471 {
472 constTensors.emplace_back(ConstTensor(managedForgetGateBias.GetTensorInfo(),
473 managedForgetGateBias.Map()));
474 }
475 if (m_BasicParameters.m_CellBias != nullptr)
476 {
477 constTensors.emplace_back(ConstTensor(managedCellBias.GetTensorInfo(),
478 managedCellBias.Map()));
479 }
480 if (m_BasicParameters.m_OutputGateBias != nullptr)
481 {
482 constTensors.emplace_back(ConstTensor(managedOutputGateBias.GetTensorInfo(),
483 managedOutputGateBias.Map()));
484 }
485
486 // Add cifig parameters
488 {
489 constTensors.emplace_back(ConstTensor(managedInputToInputWeights.GetTensorInfo(),
490 managedInputToInputWeights.Map()));
491 }
493 {
494 constTensors.emplace_back(ConstTensor(
495 managedRecurrentToInputWeights.GetTensorInfo(),
496 managedRecurrentToInputWeights.Map()));
497 }
498 if (m_CifgParameters.m_InputGateBias != nullptr)
499 {
500 constTensors.emplace_back(ConstTensor(managedInputGateBias.GetTensorInfo(),
501 managedInputGateBias.Map()));
502 }
503
504 // Add peephole parameters
506 {
507 constTensors.emplace_back(ConstTensor(managedCellToInputWeights.GetTensorInfo(),
508 managedCellToInputWeights.Map()));
509 }
511 {
512 constTensors.emplace_back(ConstTensor(managedCellToForgetWeights.GetTensorInfo(),
513 managedCellToForgetWeights.Map()));
514 }
516 {
517 constTensors.emplace_back(ConstTensor(managedCellToOutputWeights.GetTensorInfo(),
518 managedCellToOutputWeights.Map()));
519 }
520
521 // Add projection parameters
523 {
524 constTensors.emplace_back(ConstTensor(managedProjectionWeights.GetTensorInfo(),
525 managedProjectionWeights.Map()));
526 }
528 {
529 constTensors.emplace_back(ConstTensor(managedProjectionBias.GetTensorInfo(),
530 managedProjectionBias.Map()));
531 }
532
533 // Add norm parameters
535 {
536 constTensors.emplace_back(ConstTensor(managedInputLayerNormWeights.GetTensorInfo(),
537 managedInputLayerNormWeights.Map()));
538 }
540 {
541 constTensors.emplace_back(ConstTensor(managedForgetLayerNormWeights.GetTensorInfo(),
542 managedForgetLayerNormWeights.Map()));
543 }
545 {
546 constTensors.emplace_back(ConstTensor(managedCellLayerNormWeights.GetTensorInfo(),
547 managedCellLayerNormWeights.Map()));
548 }
550 {
551 constTensors.emplace_back(ConstTensor(managedOutputLayerNormWeights.GetTensorInfo(),
552 managedOutputLayerNormWeights.Map()));
553 }
554 strategy.ExecuteStrategy(this, GetParameters(), constTensors, GetName());
555}
const QLstmDescriptor & GetParameters() const override

References IStrategy::ExecuteStrategy(), Layer::GetName(), LayerWithParameters< QLstmDescriptor >::GetParameters(), ManagedConstTensorHandle::GetTensorInfo(), QLstmLayer::m_BasicParameters, QLstmBasicParameters::m_CellBias, QLstmOptLayerNormParameters::m_CellLayerNormWeights, QLstmOptPeepholeParameters::m_CellToForgetWeights, QLstmOptPeepholeParameters::m_CellToInputWeights, QLstmOptPeepholeParameters::m_CellToOutputWeights, QLstmLayer::m_CifgParameters, QLstmBasicParameters::m_ForgetGateBias, QLstmOptLayerNormParameters::m_ForgetLayerNormWeights, QLstmOptCifgParameters::m_InputGateBias, QLstmOptLayerNormParameters::m_InputLayerNormWeights, QLstmBasicParameters::m_InputToCellWeights, QLstmBasicParameters::m_InputToForgetWeights, QLstmOptCifgParameters::m_InputToInputWeights, QLstmBasicParameters::m_InputToOutputWeights, QLstmLayer::m_LayerNormParameters, QLstmBasicParameters::m_OutputGateBias, QLstmOptLayerNormParameters::m_OutputLayerNormWeights, QLstmLayer::m_PeepholeParameters, QLstmOptProjectionParameters::m_ProjectionBias, QLstmLayer::m_ProjectionParameters, QLstmOptProjectionParameters::m_ProjectionWeights, QLstmBasicParameters::m_RecurrentToCellWeights, QLstmBasicParameters::m_RecurrentToForgetWeights, QLstmOptCifgParameters::m_RecurrentToInputWeights, QLstmBasicParameters::m_RecurrentToOutputWeights, and ManagedConstTensorHandle::Map().

◆ GetConstantTensorsByRef()

Layer::ImmutableConstantTensors GetConstantTensorsByRef ( ) const
overrideprotectedvirtual

Retrieve the handles to the constant values stored by the layer.

Returns
A vector of the constant tensors stored by this layer.

Reimplemented from Layer.

Definition at line 368 of file QLstmLayer.cpp.

References QLstmLayer::m_BasicParameters, QLstmBasicParameters::m_CellBias, QLstmOptLayerNormParameters::m_CellLayerNormWeights, QLstmOptPeepholeParameters::m_CellToForgetWeights, QLstmOptPeepholeParameters::m_CellToInputWeights, QLstmOptPeepholeParameters::m_CellToOutputWeights, QLstmLayer::m_CifgParameters, QLstmBasicParameters::m_ForgetGateBias, QLstmOptLayerNormParameters::m_ForgetLayerNormWeights, QLstmOptCifgParameters::m_InputGateBias, QLstmOptLayerNormParameters::m_InputLayerNormWeights, QLstmBasicParameters::m_InputToCellWeights, QLstmBasicParameters::m_InputToForgetWeights, QLstmOptCifgParameters::m_InputToInputWeights, QLstmBasicParameters::m_InputToOutputWeights, QLstmLayer::m_LayerNormParameters, QLstmBasicParameters::m_OutputGateBias, QLstmOptLayerNormParameters::m_OutputLayerNormWeights, QLstmLayer::m_PeepholeParameters, QLstmOptProjectionParameters::m_ProjectionBias, QLstmLayer::m_ProjectionParameters, QLstmOptProjectionParameters::m_ProjectionWeights, QLstmBasicParameters::m_RecurrentToCellWeights, QLstmBasicParameters::m_RecurrentToForgetWeights, QLstmOptCifgParameters::m_RecurrentToInputWeights, and QLstmBasicParameters::m_RecurrentToOutputWeights.

◆ InferOutputShapes()

std::vector< TensorShape > InferOutputShapes ( const std::vector< TensorShape > & inputShapes) const
overridevirtual

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.

Parameters
[in]inputShapesThe input shapes layer has.
Returns
A vector to the inferred output shape.

Reimplemented from Layer.

Definition at line 153 of file QLstmLayer.cpp.

154{
155 if (inputShapes.size() != 3)
156 {
157 throw armnn::Exception("inputShapes' size is \"" + std::to_string(inputShapes.size()) +
158 "\" - should be \"3\".");
159 }
160
161 // Get input values for validation
162 unsigned int batchSize = inputShapes[0][0];
163 unsigned int outputSize = inputShapes[1][1];
164 unsigned int numUnits = inputShapes[2][1];
165
166 std::vector<TensorShape> outShapes;
167 outShapes.push_back(TensorShape({ batchSize, outputSize })); // outputStateOut
168 outShapes.push_back(TensorShape({ batchSize, numUnits })); // cellStateOut
169 outShapes.push_back(TensorShape({ batchSize, outputSize })); // output
170
171 return outShapes;
172}
Base class for all ArmNN exceptions so that users can filter to just those.

Referenced by QLstmLayer::ValidateTensorShapesFromInputs().

◆ ValidateTensorShapesFromInputs()

void ValidateTensorShapesFromInputs ( )
overridevirtual

Check if the input tensor shape(s) will lead to a valid configuration of QLstmLayer.

Parameters
[in]shapeInferenceMethodIndicates if output shape shall be overwritten or just validated.

Implements Layer.

Definition at line 174 of file QLstmLayer.cpp.

175{
177
178 const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
179
181
182 auto inferredShapes = InferOutputShapes(
183 {
184 GetInputSlot(0).GetTensorInfo().GetShape(), // input
185 GetInputSlot(1).GetTensorInfo().GetShape(), // previousOutputIn
186 GetInputSlot(2).GetTensorInfo().GetShape() // previousCellStateIn
187 });
188
189 if (inferredShapes.size() != 3)
190 {
191 throw armnn::LayerValidationException("inferredShapes has "
192 + std::to_string(inferredShapes.size()) +
193 " element(s) - should only have 3.");
194 }
195
196 // Check if the weights are nullptr for basic params
198 {
199 throw armnn::LayerValidationException("QLstmLayer: "
200 "m_BasicParameters.m_InputToForgetWeights should not be null.");
201 }
202
204 {
205 throw armnn::LayerValidationException("QLstmLayer: "
206 "m_BasicParameters.m_InputToCellWeights should not be null.");
207 }
208
210 {
211 throw armnn::LayerValidationException("QLstmLayer: "
212 "m_BasicParameters.m_InputToOutputWeights should not be null.");
213 }
214
216 {
217 throw armnn::LayerValidationException("QLstmLayer: "
218 "m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
219 }
220
222 {
223 throw armnn::LayerValidationException("QLstmLayer: "
224 "m_BasicParameters.m_RecurrentToCellWeights should not be null.");
225 }
226
228 {
229 throw armnn::LayerValidationException("QLstmLayer: "
230 "m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
231 }
232
234 {
235 throw armnn::LayerValidationException("QLstmLayer: "
236 "m_BasicParameters.m_ForgetGateBias should not be null.");
237 }
238
240 {
241 throw armnn::LayerValidationException("QLstmLayer: "
242 "m_BasicParameters.m_CellBias should not be null.");
243 }
244
246 {
247 throw armnn::LayerValidationException("QLstmLayer: "
248 "m_BasicParameters.m_OutputGateBias should not be null.");
249 }
250
252 {
254 {
255 throw armnn::LayerValidationException("QLstmLayer: "
256 "m_CifgParameters.m_InputToInputWeights should not be null.");
257 }
258
260 {
261 throw armnn::LayerValidationException("QLstmLayer: "
262 "m_CifgParameters.m_RecurrentToInputWeights should not be null.");
263 }
264
266 {
267 throw armnn::LayerValidationException("QLstmLayer: "
268 "m_CifgParameters.m_InputGateBias should not be null.");
269 }
270
271 ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "QLstmLayer");
272 }
273 else
274 {
276 {
277 throw armnn::LayerValidationException("QLstmLayer: "
278 "m_CifgParameters.m_InputToInputWeights "
279 "should not have a value when CIFG is enabled.");
280 }
281
283 {
284 throw armnn::LayerValidationException("QLstmLayer: "
285 "m_CifgParameters.m_RecurrentToInputWeights "
286 "should not have a value when CIFG is enabled.");
287 }
288
290 {
291 throw armnn::LayerValidationException("QLstmLayer: "
292 "m_CifgParameters.m_InputGateBias "
293 "should not have a value when CIFG is enabled.");
294 }
295
296 ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "QLstmLayer");
297 }
298
300 {
302 {
303 throw armnn::LayerValidationException("QLstmLayer: "
304 "m_ProjectionParameters.m_ProjectionWeights should not be null.");
305 }
306 }
307
309 {
310 if (!m_Param.m_CifgEnabled) {
312 {
313 throw armnn::LayerValidationException("QLstmLayer: "
314 "m_PeepholeParameters.m_CellToInputWeights should not be null "
315 "when Peephole is enabled and CIFG is disabled.");
316 }
317 }
318
320 {
321 throw armnn::LayerValidationException("QLstmLayer: "
322 "m_PeepholeParameters.m_CellToForgetWeights should not be null.");
323 }
324
326 {
327 throw armnn::LayerValidationException("QLstmLayer: "
328 "m_PeepholeParameters.m_CellToOutputWeights should not be null.");
329 }
330 }
331
333 GetOutputSlot(1).GetTensorInfo().GetShape(), inferredShapes[1], m_ShapeInferenceMethod, "QLstmLayer", 1);
335 GetOutputSlot(2).GetTensorInfo().GetShape(), inferredShapes[2], m_ShapeInferenceMethod, "QLstmLayer", 2);
336
338 {
340 {
342 {
343 throw armnn::LayerValidationException("QLstmLayer: m_LayerNormParameters.m_InputLayerNormWeights "
344 "should not be null.");
345 }
346 }
347
349 {
350 throw armnn::LayerValidationException("QLstmLayer: "
351 "m_LayerNormParameters.m_ForgetLayerNormWeights should not be null.");
352 }
353
355 {
356 throw armnn::LayerValidationException("QLstmLayer: "
357 "m_LayerNormParameters.m_CellLayerNormWeights should not be null.");
358 }
359
361 {
362 throw armnn::LayerValidationException("QLstmLayer: "
363 "m_LayerNormParameters.m_UutputLayerNormWeights should not be null.");
364 }
365 }
366}
#define CHECK_LOCATION()
const TensorInfo & GetTensorInfo() const override
Gets the TensorInfo for this InputSlot.
Definition Layer.cpp:614
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition Layer.cpp:410
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition Layer.hpp:337
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Definition Layer.cpp:526
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition Layer.hpp:339
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
Definition Layer.cpp:457
ShapeInferenceMethod m_ShapeInferenceMethod
Definition Layer.hpp:441
const TensorInfo & GetTensorInfo() const override
Definition Layer.cpp:100
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,...
const TensorShape & GetShape() const
Definition Tensor.hpp:193
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)

References CHECK_LOCATION, Layer::GetInputSlot(), Layer::GetOutputSlot(), TensorInfo::GetShape(), InputSlot::GetTensorInfo(), OutputSlot::GetTensorInfo(), armnnUtils::GetTensorInfo(), QLstmLayer::InferOutputShapes(), QLstmLayer::m_BasicParameters, QLstmBasicParameters::m_CellBias, QLstmOptLayerNormParameters::m_CellLayerNormWeights, QLstmOptPeepholeParameters::m_CellToForgetWeights, QLstmOptPeepholeParameters::m_CellToInputWeights, QLstmOptPeepholeParameters::m_CellToOutputWeights, QLstmDescriptor::m_CifgEnabled, QLstmLayer::m_CifgParameters, QLstmBasicParameters::m_ForgetGateBias, QLstmOptLayerNormParameters::m_ForgetLayerNormWeights, QLstmOptCifgParameters::m_InputGateBias, QLstmOptLayerNormParameters::m_InputLayerNormWeights, QLstmBasicParameters::m_InputToCellWeights, QLstmBasicParameters::m_InputToForgetWeights, QLstmOptCifgParameters::m_InputToInputWeights, QLstmBasicParameters::m_InputToOutputWeights, QLstmDescriptor::m_LayerNormEnabled, QLstmLayer::m_LayerNormParameters, QLstmBasicParameters::m_OutputGateBias, QLstmOptLayerNormParameters::m_OutputLayerNormWeights, LayerWithParameters< QLstmDescriptor >::m_Param, QLstmDescriptor::m_PeepholeEnabled, QLstmLayer::m_PeepholeParameters, QLstmDescriptor::m_ProjectionEnabled, QLstmLayer::m_ProjectionParameters, QLstmOptProjectionParameters::m_ProjectionWeights, QLstmBasicParameters::m_RecurrentToCellWeights, QLstmBasicParameters::m_RecurrentToForgetWeights, QLstmOptCifgParameters::m_RecurrentToInputWeights, QLstmBasicParameters::m_RecurrentToOutputWeights, Layer::m_ShapeInferenceMethod, Layer::ValidateAndCopyShape(), Layer::VerifyLayerConnections(), and Layer::VerifyShapeInferenceType().

Member Data Documentation

◆ m_BasicParameters

◆ m_CifgParameters

◆ m_LayerNormParameters

◆ m_PeepholeParameters

◆ m_ProjectionParameters


The documentation for this class was generated from the following files: