ArmNN
 22.02
UnidirectionalSequenceLstmLayer Class Reference

This layer represents a LSTM operation. More...

#include <UnidirectionalSequenceLstmLayer.hpp>

Inheritance diagram for UnidirectionalSequenceLstmLayer:
LayerWithParameters< LstmDescriptor > Layer IConnectableLayer

Public Member Functions

virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const override
 Makes a workload for the UnidirectionalSequence LSTM type. More...
 
UnidirectionalSequenceLstmLayerClone (Graph &graph) const override
 Creates a dynamically-allocated copy of this layer. More...
 
void ValidateTensorShapesFromInputs () override
 Check if the input tensor shape(s) will lead to a valid configuration of UnidirectionalSequenceLstmLayer. More...
 
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. More...
 
ARMNN_NO_DEPRECATE_WARN_BEGIN void Accept (ILayerVisitor &visitor) const override
 
ARMNN_NO_DEPRECATE_WARN_END void ExecuteStrategy (IStrategy &strategy) const override
 Apply a visitor to this layer. More...
 
- Public Member Functions inherited from LayerWithParameters< LstmDescriptor >
const LstmDescriptorGetParameters () const override
 If the layer has a descriptor return it. More...
 
void SerializeLayerParameters (ParameterStringifyFunction &fn) const override
 Helper to serialize the layer parameters to string (currently used in DotSerializer and company). More...
 
- 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
 
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. More...
 
DataType GetDataType () const
 
const BackendIdGetBackendId () const
 
void SetBackendId (const BackendId &id)
 
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. More...
 
unsigned int GetNumInputSlots () const override
 Returns the number of connectable input slots. More...
 
unsigned int GetNumOutputSlots () const override
 Returns the number of connectable output slots. More...
 
const InputSlotGetInputSlot (unsigned int index) const override
 Get a const input slot handle by slot index. More...
 
InputSlotGetInputSlot (unsigned int index) override
 Get the input slot handle by slot index. More...
 
const OutputSlotGetOutputSlot (unsigned int index=0) const override
 Get the const output slot handle by slot index. More...
 
OutputSlotGetOutputSlot (unsigned int index=0) override
 Get the output slot handle by slot index. More...
 
void SetGuid (LayerGuid guid)
 
LayerGuid GetGuid () const final
 Returns the unique id of the layer. More...
 
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. More...
 
Optional< BackendIdGetBackendHint () const
 
void SetShapeInferenceMethod (ShapeInferenceMethod shapeInferenceMethod)
 
template<typename T >
std::shared_ptr< T > GetAdditionalInformation () const
 
void SetAdditionalInfoForObject (const AdditionalInfoObjectPtr &additionalInfo)
 
- Public Member Functions inherited from IConnectableLayer
ARMNN_NO_DEPRECATE_WARN_BEGIN ARMNN_DEPRECATED_MSG_REMOVAL_DATE ("Accept is deprecated. The ILayerVisitor that works in conjunction with this " "Accept function is deprecated. Use IStrategy in combination with " "ExecuteStrategy instead, which is an ABI/API stable version of the " "visitor pattern.", "22.05") virtual void Accept(ILayerVisitor &visitor) const =0
 Apply a visitor to this layer. More...
 

Public Attributes

LstmBasicParameters m_BasicParameters
 
LstmOptCifgParameters m_CifgParameters
 
LstmOptProjectionParameters m_ProjectionParameters
 
LstmOptPeepholeParameters m_PeepholeParameters
 
LstmOptLayerNormParameters m_LayerNormParameters
 

Protected Member Functions

 UnidirectionalSequenceLstmLayer (const LstmDescriptor &param, const char *name)
 Constructor to create a UnidirectionalSequenceLstmLayer. More...
 
 ~UnidirectionalSequenceLstmLayer ()=default
 Default destructor. More...
 
Layer::ConstantTensors GetConstantTensorsByRef () override
 Retrieve the handles to the constant values stored by the layer. More...
 
- Protected Member Functions inherited from LayerWithParameters< LstmDescriptor >
 LayerWithParameters (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const LstmDescriptor &param, const char *name)
 
 ~LayerWithParameters ()=default
 
WorkloadInfo PrepInfoAndDesc (QueueDescriptor &descriptor) const
 Helper function to reduce duplication in *LayerCreateWorkload. More...
 
void ExecuteStrategy (IStrategy &strategy) const override
 Apply a visitor to this layer. More...
 
- 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. More...
 
template<typename LayerType , typename ... Params>
LayerTypeCloneBase (Graph &graph, Params &&... params) const
 
void SetAdditionalInfo (QueueDescriptor &descriptor) const
 
- Protected Member Functions inherited from IConnectableLayer
 ~IConnectableLayer ()
 Objects are not deletable via the handle. More...
 

Additional Inherited Members

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

Detailed Description

This layer represents a LSTM operation.

Definition at line 16 of file UnidirectionalSequenceLstmLayer.hpp.

Constructor & Destructor Documentation

◆ UnidirectionalSequenceLstmLayer()

UnidirectionalSequenceLstmLayer ( const LstmDescriptor param,
const char *  name 
)
protected

Constructor to create a UnidirectionalSequenceLstmLayer.

Parameters
[in]paramLstmDescriptor to configure the lstm operation.
[in]nameOptional name for the layer.

Definition at line 17 of file UnidirectionalSequenceLstmLayer.cpp.

References armnn::UnidirectionalSequenceLstm.

19 {
20 }
LayerWithParameters(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const LstmDescriptor &param, const char *name)

◆ ~UnidirectionalSequenceLstmLayer()

~UnidirectionalSequenceLstmLayer ( )
protecteddefault

Default destructor.

Member Function Documentation

◆ Accept()

ARMNN_NO_DEPRECATE_WARN_BEGIN void Accept ( ILayerVisitor &  visitor) const
override

Definition at line 312 of file UnidirectionalSequenceLstmLayer.cpp.

References ARMNN_NO_DEPRECATE_WARN_END, and armnn::IgnoreUnused().

313 {
314  IgnoreUnused(visitor);
315  throw armnn::Exception("UnidirectionalSequenceLstmLayer: VisitUnidirectionalSequenceLstmLayer is not implemented");
316 }
void IgnoreUnused(Ts &&...)
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46

◆ Clone()

UnidirectionalSequenceLstmLayer * 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 80 of file UnidirectionalSequenceLstmLayer.cpp.

References Layer::GetName(), UnidirectionalSequenceLstmLayer::m_BasicParameters, LstmBasicParameters::m_CellBias, LstmOptLayerNormParameters::m_CellLayerNormWeights, LstmOptPeepholeParameters::m_CellToForgetWeights, LstmOptPeepholeParameters::m_CellToInputWeights, LstmOptPeepholeParameters::m_CellToOutputWeights, UnidirectionalSequenceLstmLayer::m_CifgParameters, LstmBasicParameters::m_ForgetGateBias, LstmOptLayerNormParameters::m_ForgetLayerNormWeights, LstmOptCifgParameters::m_InputGateBias, LstmOptLayerNormParameters::m_InputLayerNormWeights, LstmBasicParameters::m_InputToCellWeights, LstmBasicParameters::m_InputToForgetWeights, LstmOptCifgParameters::m_InputToInputWeights, LstmBasicParameters::m_InputToOutputWeights, UnidirectionalSequenceLstmLayer::m_LayerNormParameters, LstmBasicParameters::m_OutputGateBias, LstmOptLayerNormParameters::m_OutputLayerNormWeights, LayerWithParameters< LstmDescriptor >::m_Param, UnidirectionalSequenceLstmLayer::m_PeepholeParameters, LstmOptProjectionParameters::m_ProjectionBias, UnidirectionalSequenceLstmLayer::m_ProjectionParameters, LstmOptProjectionParameters::m_ProjectionWeights, LstmBasicParameters::m_RecurrentToCellWeights, LstmBasicParameters::m_RecurrentToForgetWeights, LstmOptCifgParameters::m_RecurrentToInputWeights, and LstmBasicParameters::m_RecurrentToOutputWeights.

81 {
82  auto layer = CloneBase<UnidirectionalSequenceLstmLayer>(graph, m_Param, GetName());
83 
84  layer->m_BasicParameters.m_InputToForgetWeights = m_BasicParameters.m_InputToForgetWeights ?
86  : nullptr;
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 ?
100  m_BasicParameters.m_CellBias : nullptr;
101  layer->m_BasicParameters.m_OutputGateBias = m_BasicParameters.m_OutputGateBias ?
103 
104  if (!m_Param.m_CifgEnabled)
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 
114  if (m_Param.m_ProjectionEnabled)
115  {
116  layer->m_ProjectionParameters.m_ProjectionWeights = m_ProjectionParameters.m_ProjectionWeights ?
118  layer->m_ProjectionParameters.m_ProjectionBias = m_ProjectionParameters.m_ProjectionBias ?
120  }
121 
122  if (m_Param.m_PeepholeEnabled)
123  {
124  if (!m_Param.m_CifgEnabled)
125  {
126  layer->m_PeepholeParameters.m_CellToInputWeights = m_PeepholeParameters.m_CellToInputWeights ?
128  }
129  layer->m_PeepholeParameters.m_CellToForgetWeights = m_PeepholeParameters.m_CellToForgetWeights ?
131  layer->m_PeepholeParameters.m_CellToOutputWeights = m_PeepholeParameters.m_CellToOutputWeights ?
133  }
134 
135  if (m_Param.m_LayerNormEnabled)
136  {
137  layer->m_LayerNormParameters.m_InputLayerNormWeights = m_LayerNormParameters.m_InputLayerNormWeights ?
139  layer->m_LayerNormParameters.m_ForgetLayerNormWeights = m_LayerNormParameters.m_ForgetLayerNormWeights ?
141  layer->m_LayerNormParameters.m_CellLayerNormWeights = m_LayerNormParameters.m_CellLayerNormWeights ?
143  layer->m_LayerNormParameters.m_OutputLayerNormWeights = m_LayerNormParameters.m_OutputLayerNormWeights ?
145  }
146 
147  return std::move(layer);
148 }
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].
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.).
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size].
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 char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:316
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].

◆ CreateWorkload()

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

Makes a workload for the UnidirectionalSequence LSTM 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 UnidirectionalSequenceLstmLayer.cpp.

References IWorkloadFactory::CreateWorkload(), UnidirectionalSequenceLstmLayer::m_BasicParameters, LstmBasicParameters::m_CellBias, UnidirectionalSequenceLstmQueueDescriptor::m_CellBias, LstmOptLayerNormParameters::m_CellLayerNormWeights, UnidirectionalSequenceLstmQueueDescriptor::m_CellLayerNormWeights, LstmOptPeepholeParameters::m_CellToForgetWeights, UnidirectionalSequenceLstmQueueDescriptor::m_CellToForgetWeights, LstmOptPeepholeParameters::m_CellToInputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_CellToInputWeights, LstmOptPeepholeParameters::m_CellToOutputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, UnidirectionalSequenceLstmLayer::m_CifgParameters, LstmBasicParameters::m_ForgetGateBias, UnidirectionalSequenceLstmQueueDescriptor::m_ForgetGateBias, LstmOptLayerNormParameters::m_ForgetLayerNormWeights, UnidirectionalSequenceLstmQueueDescriptor::m_ForgetLayerNormWeights, LstmOptCifgParameters::m_InputGateBias, UnidirectionalSequenceLstmQueueDescriptor::m_InputGateBias, LstmOptLayerNormParameters::m_InputLayerNormWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputLayerNormWeights, LstmBasicParameters::m_InputToCellWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputToCellWeights, LstmBasicParameters::m_InputToForgetWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputToForgetWeights, LstmOptCifgParameters::m_InputToInputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputToInputWeights, LstmBasicParameters::m_InputToOutputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputToOutputWeights, LstmDescriptor::m_LayerNormEnabled, UnidirectionalSequenceLstmLayer::m_LayerNormParameters, LstmBasicParameters::m_OutputGateBias, UnidirectionalSequenceLstmQueueDescriptor::m_OutputGateBias, LstmOptLayerNormParameters::m_OutputLayerNormWeights, UnidirectionalSequenceLstmQueueDescriptor::m_OutputLayerNormWeights, LayerWithParameters< LstmDescriptor >::m_Param, LstmDescriptor::m_PeepholeEnabled, UnidirectionalSequenceLstmLayer::m_PeepholeParameters, LstmOptProjectionParameters::m_ProjectionBias, UnidirectionalSequenceLstmQueueDescriptor::m_ProjectionBias, LstmDescriptor::m_ProjectionEnabled, UnidirectionalSequenceLstmLayer::m_ProjectionParameters, LstmOptProjectionParameters::m_ProjectionWeights, UnidirectionalSequenceLstmQueueDescriptor::m_ProjectionWeights, LstmBasicParameters::m_RecurrentToCellWeights, UnidirectionalSequenceLstmQueueDescriptor::m_RecurrentToCellWeights, LstmBasicParameters::m_RecurrentToForgetWeights, UnidirectionalSequenceLstmQueueDescriptor::m_RecurrentToForgetWeights, LstmOptCifgParameters::m_RecurrentToInputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_RecurrentToInputWeights, LstmBasicParameters::m_RecurrentToOutputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_RecurrentToOutputWeights, LayerWithParameters< LstmDescriptor >::PrepInfoAndDesc(), Layer::SetAdditionalInfo(), and armnn::UnidirectionalSequenceLstm.

23 {
24  UnidirectionalSequenceLstmQueueDescriptor 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  descriptor.m_CellToForgetWeights = m_PeepholeParameters.m_CellToForgetWeights.get();
60  descriptor.m_CellToOutputWeights = m_PeepholeParameters.m_CellToOutputWeights.get();
61  }
62 
63  // Layer normalisation parameters
65  {
67  {
68  descriptor.m_InputLayerNormWeights = m_LayerNormParameters.m_InputLayerNormWeights.get();
69  }
70  descriptor.m_ForgetLayerNormWeights = m_LayerNormParameters.m_ForgetLayerNormWeights.get();
71  descriptor.m_CellLayerNormWeights = m_LayerNormParameters.m_CellLayerNormWeights.get();
72  descriptor.m_OutputLayerNormWeights = m_LayerNormParameters.m_OutputLayerNormWeights.get();
73  }
74 
75  SetAdditionalInfo(descriptor);
76 
77  return factory.CreateWorkload(LayerType::UnidirectionalSequenceLstm, descriptor, PrepInfoAndDesc(descriptor));
78 }
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.
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.).
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
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.
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size].
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Definition: Layer.cpp:248
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].
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
bool m_LayerNormEnabled
Enable/disable layer normalization.
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].

◆ ExecuteStrategy()

ARMNN_NO_DEPRECATE_WARN_END void ExecuteStrategy ( IStrategy strategy) const
overridevirtual

Apply a visitor to this layer.

Reimplemented from Layer.

Definition at line 319 of file UnidirectionalSequenceLstmLayer.cpp.

References IStrategy::ExecuteStrategy(), Layer::GetName(), LayerWithParameters< LstmDescriptor >::GetParameters(), ManagedConstTensorHandle::GetTensorInfo(), UnidirectionalSequenceLstmLayer::m_BasicParameters, LstmBasicParameters::m_CellBias, LstmOptLayerNormParameters::m_CellLayerNormWeights, LstmOptPeepholeParameters::m_CellToForgetWeights, LstmOptPeepholeParameters::m_CellToInputWeights, LstmOptPeepholeParameters::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, UnidirectionalSequenceLstmLayer::m_CifgParameters, LstmBasicParameters::m_ForgetGateBias, LstmOptLayerNormParameters::m_ForgetLayerNormWeights, LstmOptCifgParameters::m_InputGateBias, LstmOptLayerNormParameters::m_InputLayerNormWeights, LstmBasicParameters::m_InputToCellWeights, LstmBasicParameters::m_InputToForgetWeights, LstmOptCifgParameters::m_InputToInputWeights, LstmBasicParameters::m_InputToOutputWeights, LstmDescriptor::m_LayerNormEnabled, UnidirectionalSequenceLstmLayer::m_LayerNormParameters, LstmBasicParameters::m_OutputGateBias, LstmOptLayerNormParameters::m_OutputLayerNormWeights, LstmDescriptor::m_PeepholeEnabled, UnidirectionalSequenceLstmLayer::m_PeepholeParameters, LstmOptProjectionParameters::m_ProjectionBias, LstmDescriptor::m_ProjectionEnabled, UnidirectionalSequenceLstmLayer::m_ProjectionParameters, LstmOptProjectionParameters::m_ProjectionWeights, LstmBasicParameters::m_RecurrentToCellWeights, LstmBasicParameters::m_RecurrentToForgetWeights, LstmOptCifgParameters::m_RecurrentToInputWeights, LstmBasicParameters::m_RecurrentToOutputWeights, and ManagedConstTensorHandle::Map().

320 {
321  std::vector<ConstTensor> constTensors;
322 
323  LstmDescriptor descriptor = GetParameters();
324 
325  ManagedConstTensorHandle managedInputToForgetWeights(m_BasicParameters.m_InputToForgetWeights);
326  ManagedConstTensorHandle managedInputToCellWeights(m_BasicParameters.m_InputToCellWeights);
327  ManagedConstTensorHandle managedInputToOutputWeights(m_BasicParameters.m_InputToOutputWeights);
328  ManagedConstTensorHandle managedRecurrentToForgetWeights(m_BasicParameters.m_RecurrentToForgetWeights);
329  ManagedConstTensorHandle managedRecurrentToCellWeights(m_BasicParameters.m_RecurrentToCellWeights);
330  ManagedConstTensorHandle managedRecurrentToOutputWeights(m_BasicParameters.m_RecurrentToOutputWeights);
331  ManagedConstTensorHandle managedForgetGateBias(m_BasicParameters.m_ForgetGateBias);
332  ManagedConstTensorHandle managedCellBias(m_BasicParameters.m_CellBias);
333  ManagedConstTensorHandle managedOutputGateBias(m_BasicParameters.m_OutputGateBias);
334 
335  // Cifg parameters
336  ManagedConstTensorHandle managedInputToInputWeights(m_CifgParameters.m_InputToInputWeights);
337  ManagedConstTensorHandle managedRecurrentToInputWeights(m_CifgParameters.m_RecurrentToInputWeights);
338  ManagedConstTensorHandle managedInputGateBias(m_CifgParameters.m_InputGateBias);
339 
340  // Projection parameters
341  ManagedConstTensorHandle managedProjectionWeights(m_ProjectionParameters.m_ProjectionWeights);
342  ManagedConstTensorHandle managedProjectionBias(m_ProjectionParameters.m_ProjectionBias);
343 
344  // Peephole parameters
345  ManagedConstTensorHandle managedCellToInputWeights(m_PeepholeParameters.m_CellToInputWeights);
346  ManagedConstTensorHandle managedCellToForgetWeights(m_PeepholeParameters.m_CellToForgetWeights);
347  ManagedConstTensorHandle managedCellToOutputWeights(m_PeepholeParameters.m_CellToOutputWeights);
348 
349  // Layer normalisation parameters
350  ManagedConstTensorHandle managedInputLayerNormWeights(m_LayerNormParameters.m_InputLayerNormWeights);
351  ManagedConstTensorHandle managedForgetLayerNormWeights(m_LayerNormParameters.m_ForgetLayerNormWeights);
352  ManagedConstTensorHandle managedCellLayerNormWeights(m_LayerNormParameters.m_CellLayerNormWeights);
353  ManagedConstTensorHandle managedOutputLayerNormWeights(m_LayerNormParameters.m_OutputLayerNormWeights);
354 
355  // First add mandatory/basic parameters
357  {
358  constTensors.emplace_back(ConstTensor(managedInputToForgetWeights.GetTensorInfo(),
359  managedInputToForgetWeights.Map()));
360  }
362  {
363  constTensors.emplace_back(ConstTensor(managedInputToCellWeights.GetTensorInfo(),
364  managedInputToCellWeights.Map()));
365  }
367  {
368  constTensors.emplace_back(ConstTensor(managedInputToOutputWeights.GetTensorInfo(),
369  managedInputToOutputWeights.Map()));
370  }
372  {
373  constTensors.emplace_back(ConstTensor(
374  managedRecurrentToForgetWeights.GetTensorInfo(),
375  managedRecurrentToForgetWeights.Map()));
376  }
378  {
379  constTensors.emplace_back(ConstTensor(
380  managedRecurrentToCellWeights.GetTensorInfo(),
381  managedRecurrentToCellWeights.Map()));
382  }
384  {
385  constTensors.emplace_back(ConstTensor(
386  managedRecurrentToOutputWeights.GetTensorInfo(),
387  managedRecurrentToOutputWeights.Map()));
388  }
389  if (m_BasicParameters.m_ForgetGateBias != nullptr)
390  {
391  constTensors.emplace_back(ConstTensor(managedForgetGateBias.GetTensorInfo(),
392  managedForgetGateBias.Map()));
393  }
394  if (m_BasicParameters.m_CellBias != nullptr)
395  {
396  constTensors.emplace_back(ConstTensor(managedCellBias.GetTensorInfo(),
397  managedCellBias.Map()));
398  }
399  if (m_BasicParameters.m_OutputGateBias != nullptr)
400  {
401  constTensors.emplace_back(ConstTensor(managedOutputGateBias.GetTensorInfo(),
402  managedOutputGateBias.Map()));
403  }
404 
405  // Add cifg parameters
406  if (!descriptor.m_CifgEnabled)
407  {
409  {
410  constTensors.emplace_back(ConstTensor(managedInputToInputWeights.GetTensorInfo(),
411  managedInputToInputWeights.Map()));
412  }
414  {
415  constTensors.emplace_back(ConstTensor(
416  managedRecurrentToInputWeights.GetTensorInfo(),
417  managedRecurrentToInputWeights.Map()));
418  }
419  if (m_CifgParameters.m_InputGateBias != nullptr)
420  {
421  constTensors.emplace_back(ConstTensor(managedInputGateBias.GetTensorInfo(),
422  managedInputGateBias.Map()));
423  }
424  }
425 
426  // Add peephole parameters
427  if (descriptor.m_PeepholeEnabled)
428  {
429  if (!descriptor.m_CifgEnabled)
430  {
432  {
433  constTensors.emplace_back(ConstTensor(managedCellToInputWeights.GetTensorInfo(),
434  managedCellToInputWeights.Map()));
435  }
436  }
438  {
439  constTensors.emplace_back(ConstTensor(managedCellToForgetWeights.GetTensorInfo(),
440  managedCellToForgetWeights.Map()));
441  }
443  {
444  constTensors.emplace_back(ConstTensor(managedCellToOutputWeights.GetTensorInfo(),
445  managedCellToOutputWeights.Map()));
446  }
447  }
448 
449  // Add projection parameters
450  if (descriptor.m_ProjectionEnabled)
451  {
453  {
454  constTensors.emplace_back(ConstTensor(managedProjectionWeights.GetTensorInfo(),
455  managedProjectionWeights.Map()));
456  }
458  {
459  constTensors.emplace_back(ConstTensor(managedProjectionBias.GetTensorInfo(),
460  managedProjectionBias.Map()));
461  }
462  }
463 
464  // Add norm parameters
465  if (descriptor.m_LayerNormEnabled)
466  {
467  if (!descriptor.m_CifgEnabled)
468  {
470  {
471  constTensors.emplace_back(ConstTensor(managedInputLayerNormWeights.GetTensorInfo(),
472  managedInputLayerNormWeights.Map()));
473  }
474  }
476  {
477  constTensors.emplace_back(ConstTensor(managedForgetLayerNormWeights.GetTensorInfo(),
478  managedForgetLayerNormWeights.Map()));
479  }
481  {
482  constTensors.emplace_back(ConstTensor(managedCellLayerNormWeights.GetTensorInfo(),
483  managedCellLayerNormWeights.Map()));
484  }
486  {
487  constTensors.emplace_back(ConstTensor(managedOutputLayerNormWeights.GetTensorInfo(),
488  managedOutputLayerNormWeights.Map()));
489  }
490  }
491 
492  strategy.ExecuteStrategy(this, GetParameters(), constTensors, GetName());
493 }
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].
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].
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
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
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size].
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 char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:316
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].

◆ GetConstantTensorsByRef()

Layer::ConstantTensors GetConstantTensorsByRef ( )
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 277 of file UnidirectionalSequenceLstmLayer.cpp.

References ARMNN_NO_DEPRECATE_WARN_BEGIN, UnidirectionalSequenceLstmLayer::m_BasicParameters, LstmBasicParameters::m_CellBias, LstmOptLayerNormParameters::m_CellLayerNormWeights, LstmOptPeepholeParameters::m_CellToForgetWeights, LstmOptPeepholeParameters::m_CellToInputWeights, LstmOptPeepholeParameters::m_CellToOutputWeights, UnidirectionalSequenceLstmLayer::m_CifgParameters, LstmBasicParameters::m_ForgetGateBias, LstmOptLayerNormParameters::m_ForgetLayerNormWeights, LstmOptCifgParameters::m_InputGateBias, LstmOptLayerNormParameters::m_InputLayerNormWeights, LstmBasicParameters::m_InputToCellWeights, LstmBasicParameters::m_InputToForgetWeights, LstmOptCifgParameters::m_InputToInputWeights, LstmBasicParameters::m_InputToOutputWeights, UnidirectionalSequenceLstmLayer::m_LayerNormParameters, LstmBasicParameters::m_OutputGateBias, LstmOptLayerNormParameters::m_OutputLayerNormWeights, UnidirectionalSequenceLstmLayer::m_PeepholeParameters, LstmOptProjectionParameters::m_ProjectionBias, UnidirectionalSequenceLstmLayer::m_ProjectionParameters, LstmOptProjectionParameters::m_ProjectionWeights, LstmBasicParameters::m_RecurrentToCellWeights, LstmBasicParameters::m_RecurrentToForgetWeights, LstmOptCifgParameters::m_RecurrentToInputWeights, and LstmBasicParameters::m_RecurrentToOutputWeights.

278 {
279  // For API stability DO NOT ALTER order and add new members to the end of vector
289 
290  // Cifg parameters
294 
295  // Projection parameters
298 
299  // Peephole parameters
303 
304  // Layer normalisation parameters
309 }
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].
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].
std::shared_ptr< ConstTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size].
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].
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].

◆ 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 150 of file UnidirectionalSequenceLstmLayer.cpp.

References ARMNN_ASSERT, LayerWithParameters< LstmDescriptor >::m_Param, and LstmDescriptor::m_TimeMajor.

Referenced by UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs().

152 {
153  ARMNN_ASSERT(inputShapes.size() == 3);
154 
155  // Get input values for validation
156  unsigned int outputSize = inputShapes[1][1];
157 
158  std::vector<TensorShape> outShapes;
159  if (m_Param.m_TimeMajor)
160  {
161  outShapes.push_back(TensorShape({inputShapes[0][0], inputShapes[0][1], outputSize}));
162  }
163  else
164  {
165  outShapes.push_back(TensorShape({inputShapes[0][0], inputShapes[0][1], outputSize}));
166  }
167  return outShapes;
168 }
LstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
bool m_TimeMajor
Enable/disable time major.
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

◆ ValidateTensorShapesFromInputs()

void ValidateTensorShapesFromInputs ( )
overridevirtual

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

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

Implements Layer.

Definition at line 170 of file UnidirectionalSequenceLstmLayer.cpp.

References ARMNN_ASSERT, ARMNN_ASSERT_MSG, CHECK_LOCATION, InputSlot::GetConnection(), Layer::GetInputSlot(), Layer::GetOutputSlot(), TensorInfo::GetShape(), IOutputSlot::GetTensorInfo(), OutputSlot::GetTensorInfo(), UnidirectionalSequenceLstmLayer::InferOutputShapes(), UnidirectionalSequenceLstmLayer::m_BasicParameters, LstmBasicParameters::m_CellBias, LstmOptLayerNormParameters::m_CellLayerNormWeights, LstmOptPeepholeParameters::m_CellToForgetWeights, LstmOptPeepholeParameters::m_CellToInputWeights, LstmOptPeepholeParameters::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, UnidirectionalSequenceLstmLayer::m_CifgParameters, LstmBasicParameters::m_ForgetGateBias, LstmOptLayerNormParameters::m_ForgetLayerNormWeights, LstmOptCifgParameters::m_InputGateBias, LstmOptLayerNormParameters::m_InputLayerNormWeights, LstmBasicParameters::m_InputToCellWeights, LstmBasicParameters::m_InputToForgetWeights, LstmOptCifgParameters::m_InputToInputWeights, LstmBasicParameters::m_InputToOutputWeights, LstmDescriptor::m_LayerNormEnabled, UnidirectionalSequenceLstmLayer::m_LayerNormParameters, LstmBasicParameters::m_OutputGateBias, LstmOptLayerNormParameters::m_OutputLayerNormWeights, LayerWithParameters< LstmDescriptor >::m_Param, LstmDescriptor::m_PeepholeEnabled, UnidirectionalSequenceLstmLayer::m_PeepholeParameters, LstmDescriptor::m_ProjectionEnabled, UnidirectionalSequenceLstmLayer::m_ProjectionParameters, LstmOptProjectionParameters::m_ProjectionWeights, LstmBasicParameters::m_RecurrentToCellWeights, LstmBasicParameters::m_RecurrentToForgetWeights, LstmOptCifgParameters::m_RecurrentToInputWeights, LstmBasicParameters::m_RecurrentToOutputWeights, Layer::m_ShapeInferenceMethod, Layer::ValidateAndCopyShape(), Layer::VerifyLayerConnections(), and Layer::VerifyShapeInferenceType().

171 {
173 
174  const TensorShape& outputShape = GetOutputSlot(0).GetTensorInfo().GetShape();
175 
177 
178  auto inferredShapes = InferOutputShapes( {
182  });
183 
184  ARMNN_ASSERT(inferredShapes.size() == 1);
185 
186  // Check if the weights are nullptr
188  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_InputToForgetWeights should not be null.");
190  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_InputToCellWeights should not be null.");
192  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_InputToOutputWeights should not be null.");
194  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_RecurrentToForgetWeights "
195  "should not be null.");
197  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_RecurrentToCellWeights should not be null.");
199  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_RecurrentToOutputWeights "
200  "should not be null.");
202  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_ForgetGateBias should not be null.");
204  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_CellBias should not be null.");
206  "UnidirectionalSequenceLstmLayer: m_BasicParameters.m_OutputGateBias should not be null.");
207 
208  if (!m_Param.m_CifgEnabled)
209  {
211  "UnidirectionalSequenceLstmLayer: m_CifgParameters.m_InputToInputWeights should not be null.");
213  "UnidirectionalSequenceLstmLayer: m_CifgParameters.m_RecurrentToInputWeights "
214  "should not be null.");
216  "UnidirectionalSequenceLstmLayer: m_CifgParameters.m_InputGateBias should not be null.");
217  }
218  else
219  {
221  "UnidirectionalSequenceLstmLayer: m_CifgParameters.m_InputToInputWeights should not have a value "
222  "when CIFG is enabled.");
224  "UnidirectionalSequenceLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not have a value "
225  "when CIFG is enabled.");
227  "UnidirectionalSequenceLstmLayer: m_CifgParameters.m_InputGateBias should not have a value "
228  "when CIFG is enabled.");
229  }
230 
232  {
234  "UnidirectionalSequenceLstmLayer: m_ProjectionParameters.m_ProjectionWeights "
235  "should not be null.");
236  }
237 
239  {
240  if (!m_Param.m_CifgEnabled)
241  {
243  "UnidirectionalSequenceLstmLayer: m_PeepholeParameters.m_CellToInputWeights "
244  "should not be null "
245  "when Peephole is enabled and CIFG is disabled.");
246  }
248  "UnidirectionalSequenceLstmLayer: m_PeepholeParameters.m_CellToForgetWeights "
249  "should not be null.");
251  "UnidirectionalSequenceLstmLayer: m_PeepholeParameters.m_CellToOutputWeights "
252  "should not be null.");
253  }
254 
256  {
258  {
260  "UnidirectionalSequenceLstmLayer: m_LayerNormParameters.m_inputLayerNormWeights "
261  "should not be null.");
262  }
264  "UnidirectionalSequenceLstmLayer: m_LayerNormParameters.m_forgetLayerNormWeights "
265  "should not be null.");
267  "UnidirectionalSequenceLstmLayer: m_LayerNormParameters.m_cellLayerNormWeights "
268  "should not be null.");
270  "UnidirectionalSequenceLstmLayer: m_LayerNormParameters.m_outputLayerNormWeights "
271  "should not be null.");
272  }
273 
274  ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "UnidirectionalSequenceLstmLayer");
275 }
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.
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
Definition: Tensor.hpp:191
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_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
Definition: Layer.cpp:436
std::shared_ptr< ConstTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:204
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
Definition: Layer.cpp:396
std::shared_ptr< ConstTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
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
Definition: Layer.cpp:352
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:321
std::shared_ptr< ConstTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_CellBias
A unique pointer to represent 1D weights tensor with dimensions [num_units].
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
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.
std::shared_ptr< ConstTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::shared_ptr< ConstTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units].
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209
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].
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.
Definition: Layer.hpp:323
virtual const TensorInfo & GetTensorInfo() const =0
std::shared_ptr< ConstTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
std::shared_ptr< ConstTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units].
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:66
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:415
std::shared_ptr< ConstTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].

Member Data Documentation

◆ m_BasicParameters

◆ m_CifgParameters

◆ m_LayerNormParameters

◆ m_PeepholeParameters

◆ m_ProjectionParameters


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