ArmNN
 20.05
QLstmLayer Class Reference

This layer represents a QLstm operation. More...

#include <QLstmLayer.hpp>

Inheritance diagram for QLstmLayer:
LayerWithParameters< QLstmDescriptor > Layer IConnectableLayer

Public Member Functions

virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const override
 Makes a workload for the QLstm type. More...
 
QLstmLayerClone (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 QLstmLayer. 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...
 
void Accept (ILayerVisitor &visitor) const override
 Apply a visitor to this layer. More...
 
- Public Member Functions inherited from LayerWithParameters< QLstmDescriptor >
const QLstmDescriptorGetParameters () const
 
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)
 
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
 
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
 

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. More...
 
 ~QLstmLayer ()=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< 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. 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
 
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
 
- Protected Member Functions inherited from IConnectableLayer
 ~IConnectableLayer ()
 Objects are not deletable via the handle. More...
 

Additional Inherited Members

- Public Types inherited from LayerWithParameters< QLstmDescriptor >
using DescriptorType = QLstmDescriptor
 
- Protected Types inherited from Layer
using ConstantTensors = std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >>
 
- Protected Attributes inherited from LayerWithParameters< QLstmDescriptor >
QLstmDescriptor m_Param
 The parameters for the layer (not including tensor-valued weights etc.). More...
 
- Protected Attributes inherited from Layer
std::vector< OutputHandlerm_OutputHandlers
 

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.

References armnn::QLstm.

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

◆ Accept()

void Accept ( ILayerVisitor visitor) const
overridevirtual

Apply a visitor to this layer.

Implements IConnectableLayer.

Definition at line 309 of file QLstmLayer.cpp.

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

310 {
311  LstmInputParams inputParams;
312 
313  ConstTensor inputToInputWeightsTensor;
315  {
316  ConstTensor inputToInputWeightsTensorCopy(m_CifgParameters.m_InputToInputWeights->GetTensorInfo(),
318  inputToInputWeightsTensor = inputToInputWeightsTensorCopy;
319  inputParams.m_InputToInputWeights = &inputToInputWeightsTensor;
320  }
321 
322  ConstTensor inputToForgetWeightsTensor;
324  {
325  ConstTensor inputToForgetWeightsTensorCopy(m_BasicParameters.m_InputToForgetWeights->GetTensorInfo(),
327  inputToForgetWeightsTensor = inputToForgetWeightsTensorCopy;
328  inputParams.m_InputToForgetWeights = &inputToForgetWeightsTensor;
329  }
330 
331  ConstTensor inputToCellWeightsTensor;
333  {
334  ConstTensor inputToCellWeightsTensorCopy(m_BasicParameters.m_InputToCellWeights->GetTensorInfo(),
336  inputToCellWeightsTensor = inputToCellWeightsTensorCopy;
337  inputParams.m_InputToCellWeights = &inputToCellWeightsTensor;
338  }
339 
340  ConstTensor inputToOutputWeightsTensor;
342  {
343  ConstTensor inputToOutputWeightsTensorCopy(m_BasicParameters.m_InputToOutputWeights->GetTensorInfo(),
345  inputToOutputWeightsTensor = inputToOutputWeightsTensorCopy;
346  inputParams.m_InputToOutputWeights = &inputToOutputWeightsTensor;
347  }
348 
349  ConstTensor recurrentToInputWeightsTensor;
351  {
352  ConstTensor recurrentToInputWeightsTensorCopy(
355  recurrentToInputWeightsTensor = recurrentToInputWeightsTensorCopy;
356  inputParams.m_RecurrentToInputWeights = &recurrentToInputWeightsTensor;
357  }
358 
359  ConstTensor recurrentToForgetWeightsTensor;
361  {
362  ConstTensor recurrentToForgetWeightsTensorCopy(
365  recurrentToForgetWeightsTensor = recurrentToForgetWeightsTensorCopy;
366  inputParams.m_RecurrentToForgetWeights = &recurrentToForgetWeightsTensor;
367  }
368 
369  ConstTensor recurrentToCellWeightsTensor;
371  {
372  ConstTensor recurrentToCellWeightsTensorCopy(
375  recurrentToCellWeightsTensor = recurrentToCellWeightsTensorCopy;
376  inputParams.m_RecurrentToCellWeights = &recurrentToCellWeightsTensor;
377  }
378 
379  ConstTensor recurrentToOutputWeightsTensor;
381  {
382  ConstTensor recurrentToOutputWeightsTensorCopy(
385  recurrentToOutputWeightsTensor = recurrentToOutputWeightsTensorCopy;
386  inputParams.m_RecurrentToOutputWeights = &recurrentToOutputWeightsTensor;
387  }
388 
389  ConstTensor cellToInputWeightsTensor;
391  {
392  ConstTensor cellToInputWeightsTensorCopy(m_PeepholeParameters.m_CellToInputWeights->GetTensorInfo(),
394  cellToInputWeightsTensor = cellToInputWeightsTensorCopy;
395  inputParams.m_CellToInputWeights = &cellToInputWeightsTensor;
396  }
397 
398  ConstTensor cellToForgetWeightsTensor;
400  {
401  ConstTensor cellToForgetWeightsTensorCopy(m_PeepholeParameters.m_CellToForgetWeights->GetTensorInfo(),
403  cellToForgetWeightsTensor = cellToForgetWeightsTensorCopy;
404  inputParams.m_CellToForgetWeights = &cellToForgetWeightsTensor;
405  }
406 
407  ConstTensor cellToOutputWeightsTensor;
409  {
410  ConstTensor cellToOutputWeightsTensorCopy(m_PeepholeParameters.m_CellToOutputWeights->GetTensorInfo(),
412  cellToOutputWeightsTensor = cellToOutputWeightsTensorCopy;
413  inputParams.m_CellToOutputWeights = &cellToOutputWeightsTensor;
414  }
415 
416  ConstTensor inputGateBiasTensor;
417  if (m_CifgParameters.m_InputGateBias != nullptr)
418  {
419  ConstTensor inputGateBiasTensorCopy(m_CifgParameters.m_InputGateBias->GetTensorInfo(),
420  m_CifgParameters.m_InputGateBias->Map(true));
421  inputGateBiasTensor = inputGateBiasTensorCopy;
422  inputParams.m_InputGateBias = &inputGateBiasTensor;
423  }
424 
425  ConstTensor forgetGateBiasTensor;
426  if (m_BasicParameters.m_ForgetGateBias != nullptr)
427  {
428  ConstTensor forgetGateBiasTensorCopy(m_BasicParameters.m_ForgetGateBias->GetTensorInfo(),
430  forgetGateBiasTensor = forgetGateBiasTensorCopy;
431  inputParams.m_ForgetGateBias = &forgetGateBiasTensor;
432  }
433 
434  ConstTensor cellBiasTensor;
435  if (m_BasicParameters.m_CellBias != nullptr)
436  {
437  ConstTensor cellBiasTensorCopy(m_BasicParameters.m_CellBias->GetTensorInfo(),
438  m_BasicParameters.m_CellBias->Map(true));
439  cellBiasTensor = cellBiasTensorCopy;
440  inputParams.m_CellBias = &cellBiasTensor;
441  }
442 
443  ConstTensor outputGateBias;
444  if (m_BasicParameters.m_OutputGateBias != nullptr)
445  {
446  ConstTensor outputGateBiasCopy(m_BasicParameters.m_OutputGateBias->GetTensorInfo(),
448  outputGateBias = outputGateBiasCopy;
449  inputParams.m_OutputGateBias = &outputGateBias;
450  }
451 
452  ConstTensor projectionWeightsTensor;
454  {
455  ConstTensor projectionWeightsTensorCopy(m_ProjectionParameters.m_ProjectionWeights->GetTensorInfo(),
457  projectionWeightsTensor = projectionWeightsTensorCopy;
458  inputParams.m_ProjectionWeights = &projectionWeightsTensor;
459  }
460 
461  ConstTensor projectionBiasTensor;
463  {
464  ConstTensor projectionBiasTensorCopy(m_ProjectionParameters.m_ProjectionBias->GetTensorInfo(),
466  projectionBiasTensor = projectionBiasTensorCopy;
467  inputParams.m_ProjectionBias = &projectionBiasTensor;
468  }
469 
470  ConstTensor inputLayerNormTensor;
472  {
473  ConstTensor inputLayerNormTensorCopy(m_LayerNormParameters.m_InputLayerNormWeights->GetTensorInfo(),
475  inputLayerNormTensor = inputLayerNormTensorCopy;
476  inputParams.m_InputLayerNormWeights = &inputLayerNormTensor;
477  }
478 
479  ConstTensor forgetLayerNormTensor;
481  {
482  ConstTensor forgetLayerNormTensorCopy(m_LayerNormParameters.m_ForgetLayerNormWeights->GetTensorInfo(),
484  forgetLayerNormTensor = forgetLayerNormTensorCopy;
485  inputParams.m_ForgetLayerNormWeights = &forgetLayerNormTensor;
486  }
487 
488  ConstTensor cellLayerNormTensor;
490  {
491  ConstTensor cellLayerNormTensorCopy(m_LayerNormParameters.m_CellLayerNormWeights->GetTensorInfo(),
493  cellLayerNormTensor = cellLayerNormTensorCopy;
494  inputParams.m_CellLayerNormWeights = &cellLayerNormTensor;
495  }
496 
497  ConstTensor outputLayerNormTensor;
499  {
500  ConstTensor outputLayerNormTensorCopy(m_LayerNormParameters.m_OutputLayerNormWeights->GetTensorInfo(),
502  outputLayerNormTensor = outputLayerNormTensorCopy;
503  inputParams.m_OutputLayerNormWeights = &outputLayerNormTensor;
504  }
505 
506 
507  visitor.VisitQLstmLayer(this, GetParameters(), inputParams, GetName());
508 }
QLstmOptProjectionParameters m_ProjectionParameters
Definition: QLstmLayer.hpp:85
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:35
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:61
std::unique_ptr< ScopedCpuTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:73
std::unique_ptr< ScopedCpuTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:69
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:59
std::unique_ptr< ScopedCpuTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:53
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
Definition: QLstmLayer.hpp:43
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:41
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:17
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:33
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:21
std::unique_ptr< ScopedCpuTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:75
QLstmOptLayerNormParameters m_LayerNormParameters
Definition: QLstmLayer.hpp:87
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:24
std::unique_ptr< ScopedCpuTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:49
std::unique_ptr< ScopedCpuTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:51
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
Definition: QLstmLayer.hpp:63
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:71
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:19
QLstmBasicParameters m_BasicParameters
Definition: QLstmLayer.hpp:83
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:31
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:26
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:28
QLstmOptCifgParameters m_CifgParameters
Definition: QLstmLayer.hpp:84
QLstmOptPeepholeParameters m_PeepholeParameters
Definition: QLstmLayer.hpp:86
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:305

◆ 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 79 of file QLstmLayer.cpp.

References Layer::GetName(), 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, LayerWithParameters< QLstmDescriptor >::m_Param, 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.

80 {
81  auto layer = CloneBase<QLstmLayer>(graph, m_Param, GetName());
82 
83  layer->m_BasicParameters.m_InputToForgetWeights = m_BasicParameters.m_InputToForgetWeights ?
84  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_InputToForgetWeights) : nullptr;
85  layer->m_BasicParameters.m_InputToCellWeights = m_BasicParameters.m_InputToCellWeights ?
86  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_InputToCellWeights) : nullptr;
87  layer->m_BasicParameters.m_InputToOutputWeights = m_BasicParameters.m_InputToOutputWeights ?
88  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_InputToOutputWeights) : nullptr;
89  layer->m_BasicParameters.m_RecurrentToForgetWeights = m_BasicParameters.m_RecurrentToForgetWeights ?
90  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_RecurrentToForgetWeights) : nullptr;
91  layer->m_BasicParameters.m_RecurrentToCellWeights = m_BasicParameters.m_RecurrentToCellWeights ?
92  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_RecurrentToCellWeights) : nullptr;
93  layer->m_BasicParameters.m_RecurrentToOutputWeights = m_BasicParameters.m_RecurrentToOutputWeights ?
94  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_RecurrentToOutputWeights) : nullptr;
95  layer->m_BasicParameters.m_ForgetGateBias = m_BasicParameters.m_ForgetGateBias ?
96  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_ForgetGateBias) : nullptr;
97  layer->m_BasicParameters.m_CellBias = m_BasicParameters.m_CellBias ?
98  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_CellBias) : nullptr;
99  layer->m_BasicParameters.m_OutputGateBias = m_BasicParameters.m_OutputGateBias ?
100  std::make_unique<ScopedCpuTensorHandle>(*m_BasicParameters.m_OutputGateBias) : nullptr;
101 
102  if (!m_Param.m_CifgEnabled)
103  {
104  layer->m_CifgParameters.m_InputToInputWeights = m_CifgParameters.m_InputToInputWeights ?
105  std::make_unique<ScopedCpuTensorHandle>(*m_CifgParameters.m_InputToInputWeights) : nullptr;
106  layer->m_CifgParameters.m_RecurrentToInputWeights = m_CifgParameters.m_RecurrentToInputWeights ?
107  std::make_unique<ScopedCpuTensorHandle>(*m_CifgParameters.m_RecurrentToInputWeights) : nullptr;
108  layer->m_CifgParameters.m_InputGateBias = m_CifgParameters.m_InputGateBias ?
109  std::make_unique<ScopedCpuTensorHandle>(*m_CifgParameters.m_InputGateBias) : nullptr;
110  }
111 
112  if (m_Param.m_ProjectionEnabled)
113  {
114  layer->m_ProjectionParameters.m_ProjectionWeights = m_ProjectionParameters.m_ProjectionWeights ?
115  std::make_unique<ScopedCpuTensorHandle>(*m_ProjectionParameters.m_ProjectionWeights) : nullptr;
116  layer->m_ProjectionParameters.m_ProjectionBias = m_ProjectionParameters.m_ProjectionBias ?
117  std::make_unique<ScopedCpuTensorHandle>(*m_ProjectionParameters.m_ProjectionBias) : nullptr;
118  }
119 
120  if (m_Param.m_PeepholeEnabled)
121  {
122  if (!m_Param.m_CifgEnabled) {
123  layer->m_PeepholeParameters.m_CellToInputWeights = m_PeepholeParameters.m_CellToInputWeights ?
124  std::make_unique<ScopedCpuTensorHandle>(*m_PeepholeParameters.m_CellToInputWeights) : nullptr;
125  }
126 
127  layer->m_PeepholeParameters.m_CellToForgetWeights = m_PeepholeParameters.m_CellToForgetWeights ?
128  std::make_unique<ScopedCpuTensorHandle>(*m_PeepholeParameters.m_CellToForgetWeights) : nullptr;
129  layer->m_PeepholeParameters.m_CellToOutputWeights = m_PeepholeParameters.m_CellToOutputWeights ?
130  std::make_unique<ScopedCpuTensorHandle>(*m_PeepholeParameters.m_CellToOutputWeights) : nullptr;
131  }
132 
133  if (m_Param.m_LayerNormEnabled)
134  {
135  if (!m_Param.m_CifgEnabled) {
136  layer->m_LayerNormParameters.m_InputLayerNormWeights = m_LayerNormParameters.m_InputLayerNormWeights ?
137  std::make_unique<ScopedCpuTensorHandle>(*m_LayerNormParameters.m_InputLayerNormWeights) : nullptr;
138  }
139 
140  layer->m_LayerNormParameters.m_ForgetLayerNormWeights = m_LayerNormParameters.m_ForgetLayerNormWeights ?
141  std::make_unique<ScopedCpuTensorHandle>(*m_LayerNormParameters.m_ForgetLayerNormWeights) : nullptr;
142  layer->m_LayerNormParameters.m_CellLayerNormWeights = m_LayerNormParameters.m_CellLayerNormWeights ?
143  std::make_unique<ScopedCpuTensorHandle>(*m_LayerNormParameters.m_CellLayerNormWeights) : nullptr;
144  layer->m_LayerNormParameters.m_OutputLayerNormWeights = m_LayerNormParameters.m_OutputLayerNormWeights ?
145  std::make_unique<ScopedCpuTensorHandle>(*m_LayerNormParameters.m_OutputLayerNormWeights) : nullptr;
146  }
147 
148  return std::move(layer);
149 }
QLstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
QLstmOptProjectionParameters m_ProjectionParameters
Definition: QLstmLayer.hpp:85
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:35
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:61
std::unique_ptr< ScopedCpuTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:73
std::unique_ptr< ScopedCpuTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:69
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:59
std::unique_ptr< ScopedCpuTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:53
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
Definition: QLstmLayer.hpp:43
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:41
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:17
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:33
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:21
std::unique_ptr< ScopedCpuTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:75
QLstmOptLayerNormParameters m_LayerNormParameters
Definition: QLstmLayer.hpp:87
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:24
std::unique_ptr< ScopedCpuTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:49
std::unique_ptr< ScopedCpuTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:51
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
Definition: QLstmLayer.hpp:63
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:71
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:19
QLstmBasicParameters m_BasicParameters
Definition: QLstmLayer.hpp:83
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:31
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:26
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:28
QLstmOptCifgParameters m_CifgParameters
Definition: QLstmLayer.hpp:84
QLstmOptPeepholeParameters m_PeepholeParameters
Definition: QLstmLayer.hpp:86
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:305

◆ 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.

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

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  return factory.CreateQLstm(descriptor, PrepInfoAndDesc(descriptor));
77 }
QLstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
QLstmOptProjectionParameters m_ProjectionParameters
Definition: QLstmLayer.hpp:85
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:35
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:61
std::unique_ptr< ScopedCpuTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:73
bool m_PeepholeEnabled
Enable/disable peephole.
std::unique_ptr< ScopedCpuTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:69
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:59
std::unique_ptr< ScopedCpuTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:53
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
Definition: QLstmLayer.hpp:43
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:41
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:17
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:33
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:21
std::unique_ptr< ScopedCpuTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:75
QLstmOptLayerNormParameters m_LayerNormParameters
Definition: QLstmLayer.hpp:87
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:24
std::unique_ptr< ScopedCpuTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:49
bool m_LayerNormEnabled
Enable/disable layer normalization.
std::unique_ptr< ScopedCpuTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:51
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
Definition: QLstmLayer.hpp:63
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:71
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:19
QLstmBasicParameters m_BasicParameters
Definition: QLstmLayer.hpp:83
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:31
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:26
bool m_ProjectionEnabled
Enable/disable the projection layer.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:28
QLstmOptCifgParameters m_CifgParameters
Definition: QLstmLayer.hpp:84
QLstmOptPeepholeParameters m_PeepholeParameters
Definition: QLstmLayer.hpp:86
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).

◆ 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 276 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.

277 {
287 
288  // Cifg parameters
292 
293  // Projection parameters
296 
297  // Peephole parameters
301 
302  // Layer normalisation parameters
307 }
QLstmOptProjectionParameters m_ProjectionParameters
Definition: QLstmLayer.hpp:85
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:35
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:61
std::unique_ptr< ScopedCpuTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:73
std::unique_ptr< ScopedCpuTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:69
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:59
std::unique_ptr< ScopedCpuTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:53
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionBias
A unique pointer to represent 1D weights tensor with dimensions [output_size] (int32).
Definition: QLstmLayer.hpp:43
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:41
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:17
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:33
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:21
std::unique_ptr< ScopedCpuTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:75
QLstmOptLayerNormParameters m_LayerNormParameters
Definition: QLstmLayer.hpp:87
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:24
std::unique_ptr< ScopedCpuTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:49
std::unique_ptr< ScopedCpuTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:51
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
Definition: QLstmLayer.hpp:63
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:71
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:19
QLstmBasicParameters m_BasicParameters
Definition: QLstmLayer.hpp:83
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:31
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:26
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:28
QLstmOptCifgParameters m_CifgParameters
Definition: QLstmLayer.hpp:84
QLstmOptPeepholeParameters m_PeepholeParameters
Definition: QLstmLayer.hpp:86

◆ 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 151 of file QLstmLayer.cpp.

References ARMNN_ASSERT.

Referenced by QLstmInferOutputShapeImpl(), and QLstmLayer::ValidateTensorShapesFromInputs().

152 {
153  ARMNN_ASSERT(inputShapes.size() == 3);
154 
155  // Get input values for validation
156  unsigned int batchSize = inputShapes[0][0];
157  unsigned int outputSize = inputShapes[1][1];
158  unsigned int numUnits = inputShapes[2][1];
159 
160  std::vector<TensorShape> outShapes;
161  outShapes.push_back(TensorShape({ batchSize, outputSize })); // outputStateOut
162  outShapes.push_back(TensorShape({ batchSize, numUnits })); // cellStateOut
163  outShapes.push_back(TensorShape({ batchSize, outputSize })); // output
164 
165  return outShapes;
166 }
#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 QLstmLayer.

Implements Layer.

Definition at line 168 of file QLstmLayer.cpp.

References ARMNN_ASSERT, ARMNN_ASSERT_MSG, CHECK_LOCATION, InputSlot::GetConnection(), Layer::GetInputSlot(), Layer::GetOutputSlot(), TensorInfo::GetShape(), IOutputSlot::GetTensorInfo(), OutputSlot::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, and Layer::VerifyLayerConnections().

169 {
171 
172  auto inferredShapes = InferOutputShapes(
173  {
175  GetInputSlot(1).GetConnection()->GetTensorInfo().GetShape(), // previousOutputIn
176  GetInputSlot(2).GetConnection()->GetTensorInfo().GetShape() // previousCellStateIn
177  });
178 
179  ARMNN_ASSERT(inferredShapes.size() == 3);
180 
181  // Check if the weights are nullptr for basic params
183  "QLstmLayer: m_BasicParameters.m_InputToForgetWeights should not be null.");
185  "QLstmLayer: m_BasicParameters.m_InputToCellWeights should not be null.");
187  "QLstmLayer: m_BasicParameters.m_InputToOutputWeights should not be null.");
189  "QLstmLayer: m_BasicParameters.m_RecurrentToForgetWeights should not be null.");
191  "QLstmLayer: m_BasicParameters.m_RecurrentToCellWeights should not be null.");
193  "QLstmLayer: m_BasicParameters.m_RecurrentToOutputWeights should not be null.");
195  "QLstmLayer: m_BasicParameters.m_ForgetGateBias should not be null.");
197  "QLstmLayer: m_BasicParameters.m_CellBias should not be null.");
199  "QLstmLayer: m_BasicParameters.m_OutputGateBias should not be null.");
200 
201  if (!m_Param.m_CifgEnabled)
202  {
204  "QLstmLayer: m_CifgParameters.m_InputToInputWeights should not be null.");
206  "QLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should not be null.");
208  "QLstmLayer: m_CifgParameters.m_InputGateBias should not be null.");
209 
210  ConditionalThrowIfNotEqual<LayerValidationException>(
211  "QLstmLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
213  inferredShapes[0]);
214  }
215  else
216  {
218  "QLstmLayer: m_CifgParameters.m_InputToInputWeights should not have a value when CIFG is enabled.");
220  "QLstmLayer: m_CifgParameters.m_RecurrentToInputWeights should "
221  "not have a value when CIFG is enabled.");
223  "QLstmLayer: m_CifgParameters.m_InputGateBias should not have a value when CIFG is enabled.");
224 
225  ConditionalThrowIfNotEqual<LayerValidationException>(
226  "QLstmLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
228  inferredShapes[0]);
229  }
230 
232  {
234  "QLstmLayer: m_ProjectionParameters.m_ProjectionWeights should not be null.");
235  }
236 
238  {
239  if (!m_Param.m_CifgEnabled) {
241  "QLstmLayer: m_PeepholeParameters.m_CellToInputWeights should not be null "
242  "when Peephole is enabled and CIFG is disabled.");
243  }
244 
246  "QLstmLayer: m_PeepholeParameters.m_CellToForgetWeights should not be null.");
248  "QLstmLayer: m_PeepholeParameters.m_CellToOutputWeights should not be null.");
249  }
250 
251  ConditionalThrowIfNotEqual<LayerValidationException>(
252  "QLstmLayer: TensorShape set on OutputSlot[1] does not match the inferred shape.",
254  inferredShapes[1]);
255  ConditionalThrowIfNotEqual<LayerValidationException>(
256  "QLstmLayer: TensorShape set on OutputSlot[2] does not match the inferred shape.",
258  inferredShapes[2]);
259 
261  {
263  {
265  "QLstmLayer: m_LayerNormParameters.m_InputLayerNormWeights should not be null.");
266  }
268  "QLstmLayer: m_LayerNormParameters.m_ForgetLayerNormWeights should not be null.");
270  "QLstmLayer: m_LayerNormParameters.m_CellLayerNormWeights should not be null.");
272  "QLstmLayer: m_LayerNormParameters.m_UutputLayerNormWeights should not be null.");
273  }
274 }
QLstmDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
QLstmOptProjectionParameters m_ProjectionParameters
Definition: QLstmLayer.hpp:85
std::unique_ptr< ScopedCpuTensorHandle > m_OutputGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:35
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:61
std::unique_ptr< ScopedCpuTensorHandle > m_CellLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:73
bool m_PeepholeEnabled
Enable/disable peephole.
std::unique_ptr< ScopedCpuTensorHandle > m_InputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:69
std::unique_ptr< ScopedCpuTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:59
std::unique_ptr< ScopedCpuTensorHandle > m_CellToOutputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:53
std::unique_ptr< ScopedCpuTensorHandle > m_ProjectionWeights
A unique pointer to represent 2D weights tensor with dimensions [output_size, num_units] (QSymmS8)...
Definition: QLstmLayer.hpp:41
std::unique_ptr< ScopedCpuTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:17
std::unique_ptr< ScopedCpuTensorHandle > m_CellBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:33
std::unique_ptr< ScopedCpuTensorHandle > m_InputToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:21
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
std::unique_ptr< ScopedCpuTensorHandle > m_OutputLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:75
QLstmOptLayerNormParameters m_LayerNormParameters
Definition: QLstmLayer.hpp:87
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:24
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:339
std::unique_ptr< ScopedCpuTensorHandle > m_CellToInputWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:49
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
bool m_LayerNormEnabled
Enable/disable layer normalization.
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
std::unique_ptr< ScopedCpuTensorHandle > m_CellToForgetWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:51
std::unique_ptr< ScopedCpuTensorHandle > m_InputGateBias
A unique pointer to represent 1D weights tensor with dimensions [num_units] (int32).
Definition: QLstmLayer.hpp:63
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetLayerNormWeights
A unique pointer to represent 1D weights tensor with dimensions [num_units] (QSymmS16).
Definition: QLstmLayer.hpp:71
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192
std::unique_ptr< ScopedCpuTensorHandle > m_InputToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:19
QLstmBasicParameters m_BasicParameters
Definition: QLstmLayer.hpp:83
std::unique_ptr< ScopedCpuTensorHandle > m_ForgetGateBias
A unique pointer to represent 1D bias tensor with dimensions [num_units] (int32). ...
Definition: QLstmLayer.hpp:31
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToCellWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:26
bool m_ProjectionEnabled
Enable/disable the projection layer.
std::unique_ptr< ScopedCpuTensorHandle > m_RecurrentToOutputWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, outputSize] (QSymmS8)...
Definition: QLstmLayer.hpp:28
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
virtual const TensorInfo & GetTensorInfo() const =0
QLstmOptCifgParameters m_CifgParameters
Definition: QLstmLayer.hpp:84
QLstmOptPeepholeParameters m_PeepholeParameters
Definition: QLstmLayer.hpp:86
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.
Definition: QLstmLayer.cpp:151
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:63
bool m_CifgEnabled
Enable/disable CIFG (coupled input & forget gate).

Member Data Documentation

◆ m_BasicParameters

◆ m_CifgParameters

◆ m_LayerNormParameters

◆ m_PeepholeParameters

◆ m_ProjectionParameters


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