ArmNN
 25.02
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UnidirectionalSequenceLstmQueueDescriptor Struct Reference

#include <WorkloadData.hpp>

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

Public Member Functions

 UnidirectionalSequenceLstmQueueDescriptor ()
 
void Validate (const WorkloadInfo &workloadInfo) const
 
- Public Member Functions inherited from QueueDescriptorWithParameters< LstmDescriptor >
virtual ~QueueDescriptorWithParameters ()=default
 
- Public Member Functions inherited from QueueDescriptor
virtual ~QueueDescriptor ()=default
 
void ValidateTensorNumDimensions (const TensorInfo &tensor, std::string const &descName, unsigned int numDimensions, std::string const &tensorName) const
 
void ValidateTensorNumDimNumElem (const TensorInfo &tensorInfo, unsigned int numDimension, unsigned int numElements, std::string const &tensorName) const
 
void ValidateInputsOutputs (const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
 
template<typename T >
const T * GetAdditionalInformation () const
 

Public Attributes

const ConstTensorHandlem_InputToInputWeights
 
const ConstTensorHandlem_InputToForgetWeights
 
const ConstTensorHandlem_InputToCellWeights
 
const ConstTensorHandlem_InputToOutputWeights
 
const ConstTensorHandlem_RecurrentToInputWeights
 
const ConstTensorHandlem_RecurrentToForgetWeights
 
const ConstTensorHandlem_RecurrentToCellWeights
 
const ConstTensorHandlem_RecurrentToOutputWeights
 
const ConstTensorHandlem_CellToInputWeights
 
const ConstTensorHandlem_CellToForgetWeights
 
const ConstTensorHandlem_CellToOutputWeights
 
const ConstTensorHandlem_InputGateBias
 
const ConstTensorHandlem_ForgetGateBias
 
const ConstTensorHandlem_CellBias
 
const ConstTensorHandlem_OutputGateBias
 
const ConstTensorHandlem_ProjectionWeights
 
const ConstTensorHandlem_ProjectionBias
 
const ConstTensorHandlem_InputLayerNormWeights
 
const ConstTensorHandlem_ForgetLayerNormWeights
 
const ConstTensorHandlem_CellLayerNormWeights
 
const ConstTensorHandlem_OutputLayerNormWeights
 
- Public Attributes inherited from QueueDescriptorWithParameters< LstmDescriptor >
LstmDescriptor m_Parameters
 
- Public Attributes inherited from QueueDescriptor
std::vector< ITensorHandle * > m_Inputs
 
std::vector< ITensorHandle * > m_Outputs
 
void * m_AdditionalInfoObject
 
bool m_AllowExpandedDims = false
 

Additional Inherited Members

- Protected Member Functions inherited from QueueDescriptorWithParameters< LstmDescriptor >
 QueueDescriptorWithParameters ()=default
 
 QueueDescriptorWithParameters (QueueDescriptorWithParameters const &)=default
 
QueueDescriptorWithParametersoperator= (QueueDescriptorWithParameters const &)=default
 
- Protected Member Functions inherited from QueueDescriptor
 QueueDescriptor ()
 
 QueueDescriptor (QueueDescriptor const &)=default
 
QueueDescriptoroperator= (QueueDescriptor const &)=default
 

Detailed Description

Definition at line 696 of file WorkloadData.hpp.

Constructor & Destructor Documentation

◆ UnidirectionalSequenceLstmQueueDescriptor()

Definition at line 698 of file WorkloadData.hpp.

699  : m_InputToInputWeights(nullptr)
700  , m_InputToForgetWeights(nullptr)
701  , m_InputToCellWeights(nullptr)
702  , m_InputToOutputWeights(nullptr)
703  , m_RecurrentToInputWeights(nullptr)
704  , m_RecurrentToForgetWeights(nullptr)
705  , m_RecurrentToCellWeights(nullptr)
706  , m_RecurrentToOutputWeights(nullptr)
707  , m_CellToInputWeights(nullptr)
708  , m_CellToForgetWeights(nullptr)
709  , m_CellToOutputWeights(nullptr)
710  , m_InputGateBias(nullptr)
711  , m_ForgetGateBias(nullptr)
712  , m_CellBias(nullptr)
713  , m_OutputGateBias(nullptr)
714  , m_ProjectionWeights(nullptr)
715  , m_ProjectionBias(nullptr)
716  , m_InputLayerNormWeights(nullptr)
717  , m_ForgetLayerNormWeights(nullptr)
718  , m_CellLayerNormWeights(nullptr)
719  , m_OutputLayerNormWeights(nullptr)
720  {
721  }
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_RecurrentToForgetWeights

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 3935 of file WorkloadData.cpp.

3936 {
3937  // Modified from LstmQueueDescriptor::Validate to support UnidirectionalSequenceLstm
3938 
3939  const std::string descriptorName{"UnidirectionalSequenceLstmQueueDescriptor"};
3940 
3941  // check dimensions of all inputs and outputs
3942  if (workloadInfo.m_InputTensorInfos.size() != 3)
3943  {
3944  throw InvalidArgumentException(descriptorName + ": Invalid number of inputs.");
3945  }
3946  if (workloadInfo.m_OutputTensorInfos.size() != 3)
3947  {
3948  throw InvalidArgumentException(descriptorName + ": Invalid number of outputs.");
3949  }
3950 
3951  std::vector<DataType> supportedTypes =
3952  {
3955  };
3956 
3957  // check for supported type of one input and match them with all the other input and output
3958  ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], supportedTypes, descriptorName);
3959 
3960  // Making sure clipping parameters have valid values.
3961  // == 0 means no clipping
3962  // > 0 means clipping
3963  if (m_Parameters.m_ClippingThresCell < 0.0f)
3964  {
3965  throw InvalidArgumentException(descriptorName + ": negative cell clipping threshold is invalid");
3966  }
3967  if (m_Parameters.m_ClippingThresProj < 0.0f)
3968  {
3969  throw InvalidArgumentException(descriptorName + ": negative projection clipping threshold is invalid");
3970  }
3971 
3972  unsigned int batchIndx = 0;
3973  unsigned int inputIndx = 1;
3974  uint32_t timeStep = 1;
3975  unsigned int timeIndx = 1;
3976  inputIndx = 2;
3978  {
3979  batchIndx = 1;
3980  timeIndx = 0;
3981 
3982  }
3983  timeStep = workloadInfo.m_InputTensorInfos[0].GetShape()[timeIndx];
3984 
3985  // Inferring batch size, number of outputs and number of cells from the inputs.
3986  const uint32_t n_input = workloadInfo.m_InputTensorInfos[0].GetShape()[inputIndx];
3987  const uint32_t n_batch = workloadInfo.m_InputTensorInfos[0].GetShape()[batchIndx];
3988  ValidatePointer(m_InputToOutputWeights, "Null pointer check", "InputToOutputWeights");
3989  const uint32_t n_cell = m_InputToOutputWeights->GetShape()[0];
3990  ValidatePointer(m_RecurrentToOutputWeights, "Null pointer check", "RecurrentToOutputWeights");
3991  const uint32_t n_output = m_RecurrentToOutputWeights->GetShape()[1];
3992 
3993  // input tensor
3994  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[0], 3, (timeStep * n_batch * n_input),
3995  descriptorName + " input_0");
3996  // outputStateInTensor
3997  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[1], 2, (n_batch * n_output),
3998  descriptorName + " input_1");
3999  // outputStateInTensor
4000  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[2], 2, (n_batch * n_cell),
4001  descriptorName + " input_2");
4002 
4003  // outputTensor
4004  ValidateTensorNumDimNumElem(workloadInfo.m_OutputTensorInfos[2], 3, (timeStep * n_batch * n_output),
4005  descriptorName + " output_0");
4006 
4007  // check that dimensions of inputs/outputs and QueueDescriptor data match with each other
4008  if ( m_InputToInputWeights )
4009  {
4011  (n_cell * n_input), "InputLayerNormWeights");
4012  }
4013 
4014  ValidatePointer(m_InputToForgetWeights, "Null pointer check", "InputToForgetWeights");
4016  (n_cell * n_input), "InputToForgetWeights");
4017 
4018  ValidatePointer(m_InputToCellWeights, "Null pointer check", "InputToCellWeights");
4020  (n_cell * n_input), "InputToCellWeights");
4021 
4023  {
4025  (n_cell * n_output), "RecurrentToInputWeights");
4026  }
4027 
4028  ValidatePointer(m_RecurrentToForgetWeights, "Null pointer check", "RecurrentToForgetWeights");
4030  (n_cell * n_output), "RecurrentToForgetWeights");
4031 
4032  ValidatePointer(m_RecurrentToCellWeights, "Null pointer check", "RecurrentToCellWeights");
4034  (n_cell * n_output), "RecurrentToCellWeights");
4035 
4036  // Make sure the input-gate's parameters are either both present (regular
4037  // LSTM) or not at all (CIFG-LSTM). And CifgEnable is set accordingly.
4038  bool cifg_weights_all_or_none = ((m_InputToInputWeights && m_RecurrentToInputWeights &&
4042  if (!cifg_weights_all_or_none)
4043  {
4044  throw InvalidArgumentException(descriptorName + ": Input-Gate's parameters InputToInputWeights and "
4045  "RecurrentToInputWeights must either both be present (regular LSTM) "
4046  "or both not present (CIFG-LSTM). In addition CifgEnable must be set "
4047  "accordingly.");
4048  }
4049 
4050  if ( m_CellToInputWeights )
4051  {
4053  n_cell, "CellToInputWeights");
4054  }
4055  if ( m_CellToForgetWeights )
4056  {
4058  n_cell, "CellToForgetWeights");
4059  }
4060  if ( m_CellToOutputWeights )
4061  {
4063  n_cell, "CellToOutputWeights");
4064  }
4065 
4066  // Making sure the peephole weights are there all or none. And PeepholeEnable is set accordingly.
4067  bool peephole_weights_all_or_none =
4072  if (!peephole_weights_all_or_none)
4073  {
4074  throw InvalidArgumentException(descriptorName + ": Invalid combination of peephole parameters.");
4075  }
4076 
4077  // Make sure the input gate bias is present only when not a CIFG-LSTM.
4079  {
4080  if (m_InputGateBias)
4081  {
4082  throw InvalidArgumentException(descriptorName + ": InputGateBias is present and CIFG-LSTM is enabled.");
4083  }
4084  }
4085  else
4086  {
4087  if (!m_InputGateBias)
4088  {
4089  throw InvalidArgumentException(descriptorName + ": If CIFG-LSTM is disabled InputGateBias "
4090  "must be present.");
4091  }
4093  n_cell, "InputGateBias");
4094  }
4095 
4096  ValidatePointer(m_ForgetGateBias, "Null pointer check", "ForgetGateBias");
4097  ValidateTensorNumDimNumElem(m_ForgetGateBias->GetTensorInfo(), 1, n_cell, "ForgetGateBias");
4098 
4099  ValidatePointer(m_CellBias, "Null pointer check", "CellBias");
4100  ValidateTensorNumDimNumElem(m_CellBias->GetTensorInfo(), 1, n_cell, "CellBias");
4101 
4102  ValidatePointer(m_OutputGateBias, "Null pointer check", "OutputGateBias");
4103  ValidateTensorNumDimNumElem(m_OutputGateBias->GetTensorInfo(), 1, n_cell, "OutputGateBias");
4104 
4105  if (m_ProjectionWeights)
4106  {
4108  (n_cell * n_output), "ProjectionWeights");
4109  }
4110  if (m_ProjectionBias)
4111  {
4112  ValidateTensorNumDimNumElem(m_ProjectionBias->GetTensorInfo(), 1, n_output, "ProjectionBias");
4113  }
4114 
4115  // Making sure the projection tensors are consistent:
4116  // 1) If projection weight is not present, then projection bias should not be
4117  // present.
4118  // 2) If projection weight is present, then projection bias is optional.
4119  bool projecton_tensors_consistent = ((!m_ProjectionWeights && !m_ProjectionBias &&
4125  if (!projecton_tensors_consistent)
4126  {
4127  throw InvalidArgumentException(descriptorName + ": Projection tensors are inconsistent.");
4128  }
4129 
4130  // The four layer normalization weights either all have values or none of them have values. Additionally, if
4131  // CIFG is used, input layer normalization weights tensor is omitted and the other layer normalization weights
4132  // either all have values or none of them have values. Layer normalization is used when the values of all the
4133  // layer normalization weights are present
4135  {
4136  ValidateTensorNumDimNumElem(m_InputLayerNormWeights->GetTensorInfo(), 1, n_cell, "InputLayerNormWeights");
4137  }
4139  {
4140  ValidateTensorNumDimNumElem(m_ForgetLayerNormWeights->GetTensorInfo(), 1, n_cell, "ForgetLayerNormWeights");
4141  }
4143  {
4144  ValidateTensorNumDimNumElem(m_CellLayerNormWeights->GetTensorInfo(), 1, n_cell, "CellLayerNormWeights");
4145  }
4147  {
4148  ValidateTensorNumDimNumElem(m_OutputLayerNormWeights->GetTensorInfo(), 1, n_cell, "OutputLayerNormWeights");
4149  }
4150 
4152  {
4154  {
4156  {
4157  throw InvalidArgumentException(descriptorName + ": Layer normalisation is enabled and CIFG-LSTM is "
4158  "disabled but InputLayerNormWeights are not present");
4159  }
4161  1, n_cell, "InputLayerNormWeights");
4162  }
4163  else if (m_InputLayerNormWeights)
4164  {
4165  throw InvalidArgumentException(descriptorName + ":InputLayerNormWeights are present while CIFG is "
4166  "enabled");
4167  }
4168 
4169  ValidatePointer(m_ForgetLayerNormWeights, "Null pointer check layer normalisation enabled",
4170  "ForgetLayerNormWeights");
4171  ValidateTensorNumDimNumElem(m_ForgetLayerNormWeights->GetTensorInfo(), 1, n_cell, "ForgetLayerNormWeights");
4172 
4173  ValidatePointer(m_OutputLayerNormWeights, "Null pointer check layer normalisation enabled",
4174  "OutputLayerNormWeights");
4175  ValidateTensorNumDimNumElem(m_OutputLayerNormWeights->GetTensorInfo(), 1, n_cell, "OutputLayerNormWeights");
4176 
4177  ValidatePointer(m_CellLayerNormWeights, "Null pointer check layer normalisation enabled",
4178  "CellLayerNormWeights");
4179  ValidateTensorNumDimNumElem(m_CellLayerNormWeights->GetTensorInfo(), 1, n_cell, "CellLayerNormWeights");
4180  }
4182  {
4183  throw InvalidArgumentException(descriptorName + ": Layer normalisation is disabled but one or more layer "
4184  "normalisation weights are present.");
4185  }
4186 }
const TensorInfo & GetTensorInfo() const
TensorShape GetShape() const override
Get the number of elements for each dimension ordered from slowest iterating dimension to fastest ite...
bool m_PeepholeEnabled
Enable/disable peephole.
bool m_TimeMajor
Enable/disable time major.
bool m_LayerNormEnabled
Enable/disable layer normalization.
float m_ClippingThresCell
Clipping threshold value for the cell state.
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_ClippingThresProj
Clipping threshold value for the projection.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
void ValidateTensorNumDimNumElem(const TensorInfo &tensorInfo, unsigned int numDimension, unsigned int numElements, std::string const &tensorName) const
std::vector< TensorInfo > m_OutputTensorInfos
std::vector< TensorInfo > m_InputTensorInfos

References armnn::Float32, ConstTensorHandle::GetShape(), ConstTensorHandle::GetTensorInfo(), UnidirectionalSequenceLstmQueueDescriptor::m_CellBias, UnidirectionalSequenceLstmQueueDescriptor::m_CellLayerNormWeights, UnidirectionalSequenceLstmQueueDescriptor::m_CellToForgetWeights, UnidirectionalSequenceLstmQueueDescriptor::m_CellToInputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_CellToOutputWeights, LstmDescriptor::m_CifgEnabled, LstmDescriptor::m_ClippingThresCell, LstmDescriptor::m_ClippingThresProj, UnidirectionalSequenceLstmQueueDescriptor::m_ForgetGateBias, UnidirectionalSequenceLstmQueueDescriptor::m_ForgetLayerNormWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputGateBias, UnidirectionalSequenceLstmQueueDescriptor::m_InputLayerNormWeights, WorkloadInfo::m_InputTensorInfos, UnidirectionalSequenceLstmQueueDescriptor::m_InputToCellWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputToForgetWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputToInputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_InputToOutputWeights, LstmDescriptor::m_LayerNormEnabled, UnidirectionalSequenceLstmQueueDescriptor::m_OutputGateBias, UnidirectionalSequenceLstmQueueDescriptor::m_OutputLayerNormWeights, WorkloadInfo::m_OutputTensorInfos, QueueDescriptorWithParameters< LstmDescriptor >::m_Parameters, LstmDescriptor::m_PeepholeEnabled, UnidirectionalSequenceLstmQueueDescriptor::m_ProjectionBias, LstmDescriptor::m_ProjectionEnabled, UnidirectionalSequenceLstmQueueDescriptor::m_ProjectionWeights, UnidirectionalSequenceLstmQueueDescriptor::m_RecurrentToCellWeights, UnidirectionalSequenceLstmQueueDescriptor::m_RecurrentToForgetWeights, UnidirectionalSequenceLstmQueueDescriptor::m_RecurrentToInputWeights, UnidirectionalSequenceLstmQueueDescriptor::m_RecurrentToOutputWeights, LstmDescriptor::m_TimeMajor, armnn::QAsymmS8, and QueueDescriptor::ValidateTensorNumDimNumElem().

Member Data Documentation

◆ m_CellBias

◆ m_CellLayerNormWeights

◆ m_CellToForgetWeights

◆ m_CellToInputWeights

◆ m_CellToOutputWeights

◆ m_ForgetGateBias

◆ m_ForgetLayerNormWeights

◆ m_InputGateBias

◆ m_InputLayerNormWeights

◆ m_InputToCellWeights

◆ m_InputToForgetWeights

◆ m_InputToInputWeights

◆ m_InputToOutputWeights

◆ m_OutputGateBias

◆ m_OutputLayerNormWeights

◆ m_ProjectionBias

◆ m_ProjectionWeights

◆ m_RecurrentToCellWeights

◆ m_RecurrentToForgetWeights

◆ m_RecurrentToInputWeights

◆ m_RecurrentToOutputWeights


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