ArmNN
 22.05
UnidirectionalSequenceLstmQueueDescriptor Struct Reference

#include <WorkloadData.hpp>

Inheritance diagram for UnidirectionalSequenceLstmQueueDescriptor:
QueueDescriptorWithParameters< LstmDescriptor > QueueDescriptor

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 731 of file WorkloadData.hpp.

Constructor & Destructor Documentation

◆ UnidirectionalSequenceLstmQueueDescriptor()

Definition at line 733 of file WorkloadData.hpp.

734  : m_InputToInputWeights(nullptr)
735  , m_InputToForgetWeights(nullptr)
736  , m_InputToCellWeights(nullptr)
737  , m_InputToOutputWeights(nullptr)
738  , m_RecurrentToInputWeights(nullptr)
739  , m_RecurrentToForgetWeights(nullptr)
740  , m_RecurrentToCellWeights(nullptr)
741  , m_RecurrentToOutputWeights(nullptr)
742  , m_CellToInputWeights(nullptr)
743  , m_CellToForgetWeights(nullptr)
744  , m_CellToOutputWeights(nullptr)
745  , m_InputGateBias(nullptr)
746  , m_ForgetGateBias(nullptr)
747  , m_CellBias(nullptr)
748  , m_OutputGateBias(nullptr)
749  , m_ProjectionWeights(nullptr)
750  , m_ProjectionBias(nullptr)
751  , m_InputLayerNormWeights(nullptr)
752  , m_ForgetLayerNormWeights(nullptr)
753  , m_CellLayerNormWeights(nullptr)
754  , m_OutputLayerNormWeights(nullptr)
755  {
756  }
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_RecurrentToForgetWeights

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 3893 of file WorkloadData.cpp.

References armnn::Float32, WorkloadInfo::m_InputTensorInfos, WorkloadInfo::m_OutputTensorInfos, armnn::QAsymmS8, and QueueDescriptor::ValidateTensorNumDimNumElem().

3894 {
3895  // Modified from LstmQueueDescriptor::Validate to support UnidirectionalSequenceLstm
3896 
3897  const std::string descriptorName{"UnidirectionalSequenceLstmQueueDescriptor"};
3898 
3899  // check dimensions of all inputs and outputs
3900  if (workloadInfo.m_InputTensorInfos.size() != 3)
3901  {
3902  throw InvalidArgumentException(descriptorName + ": Invalid number of inputs.");
3903  }
3904  if (workloadInfo.m_OutputTensorInfos.size() != 3)
3905  {
3906  throw InvalidArgumentException(descriptorName + ": Invalid number of outputs.");
3907  }
3908 
3909  std::vector<DataType> supportedTypes =
3910  {
3913  };
3914 
3915  // check for supported type of one input and match them with all the other input and output
3916  ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], supportedTypes, descriptorName);
3917 
3918  // Making sure clipping parameters have valid values.
3919  // == 0 means no clipping
3920  // > 0 means clipping
3921  if (m_Parameters.m_ClippingThresCell < 0.0f)
3922  {
3923  throw InvalidArgumentException(descriptorName + ": negative cell clipping threshold is invalid");
3924  }
3925  if (m_Parameters.m_ClippingThresProj < 0.0f)
3926  {
3927  throw InvalidArgumentException(descriptorName + ": negative projection clipping threshold is invalid");
3928  }
3929 
3930  unsigned int batchIndx = 0;
3931  unsigned int inputIndx = 1;
3932  uint32_t timeStep = 1;
3933  unsigned int timeIndx = 1;
3934  inputIndx = 2;
3936  {
3937  batchIndx = 1;
3938  timeIndx = 0;
3939 
3940  }
3941  timeStep = workloadInfo.m_InputTensorInfos[0].GetShape()[timeIndx];
3942 
3943  // Inferring batch size, number of outputs and number of cells from the inputs.
3944  const uint32_t n_input = workloadInfo.m_InputTensorInfos[0].GetShape()[inputIndx];
3945  const uint32_t n_batch = workloadInfo.m_InputTensorInfos[0].GetShape()[batchIndx];
3946  ValidatePointer(m_InputToOutputWeights, "Null pointer check", "InputToOutputWeights");
3947  const uint32_t n_cell = m_InputToOutputWeights->GetShape()[0];
3948  ValidatePointer(m_RecurrentToOutputWeights, "Null pointer check", "RecurrentToOutputWeights");
3949  const uint32_t n_output = m_RecurrentToOutputWeights->GetShape()[1];
3950 
3951  // input tensor
3952  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[0], 3, (timeStep * n_batch * n_input),
3953  descriptorName + " input_0");
3954  // outputStateInTensor
3955  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[1], 2, (n_batch * n_output),
3956  descriptorName + " input_1");
3957  // outputStateInTensor
3958  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[2], 2, (n_batch * n_cell),
3959  descriptorName + " input_2");
3960 
3961  // outputTensor
3962  ValidateTensorNumDimNumElem(workloadInfo.m_OutputTensorInfos[2], 3, (timeStep * n_batch * n_output),
3963  descriptorName + " output_0");
3964 
3965  // check that dimensions of inputs/outputs and QueueDescriptor data match with each other
3966  if ( m_InputToInputWeights )
3967  {
3969  (n_cell * n_input), "InputLayerNormWeights");
3970  }
3971 
3972  ValidatePointer(m_InputToForgetWeights, "Null pointer check", "InputToForgetWeights");
3974  (n_cell * n_input), "InputToForgetWeights");
3975 
3976  ValidatePointer(m_InputToCellWeights, "Null pointer check", "InputToCellWeights");
3978  (n_cell * n_input), "InputToCellWeights");
3979 
3981  {
3983  (n_cell * n_output), "RecurrentToInputWeights");
3984  }
3985 
3986  ValidatePointer(m_RecurrentToForgetWeights, "Null pointer check", "RecurrentToForgetWeights");
3988  (n_cell * n_output), "RecurrentToForgetWeights");
3989 
3990  ValidatePointer(m_RecurrentToCellWeights, "Null pointer check", "RecurrentToCellWeights");
3992  (n_cell * n_output), "RecurrentToCellWeights");
3993 
3994  // Make sure the input-gate's parameters are either both present (regular
3995  // LSTM) or not at all (CIFG-LSTM). And CifgEnable is set accordingly.
3996  bool cifg_weights_all_or_none = ((m_InputToInputWeights && m_RecurrentToInputWeights &&
4000  if (!cifg_weights_all_or_none)
4001  {
4002  throw InvalidArgumentException(descriptorName + ": Input-Gate's parameters InputToInputWeights and "
4003  "RecurrentToInputWeights must either both be present (regular LSTM) "
4004  "or both not present (CIFG-LSTM). In addition CifgEnable must be set "
4005  "accordingly.");
4006  }
4007 
4008  if ( m_CellToInputWeights )
4009  {
4011  n_cell, "CellToInputWeights");
4012  }
4013  if ( m_CellToForgetWeights )
4014  {
4016  n_cell, "CellToForgetWeights");
4017  }
4018  if ( m_CellToOutputWeights )
4019  {
4021  n_cell, "CellToOutputWeights");
4022  }
4023 
4024  // Making sure the peephole weights are there all or none. And PeepholeEnable is set accordingly.
4025  bool peephole_weights_all_or_none =
4030  if (!peephole_weights_all_or_none)
4031  {
4032  throw InvalidArgumentException(descriptorName + ": Invalid combination of peephole parameters.");
4033  }
4034 
4035  // Make sure the input gate bias is present only when not a CIFG-LSTM.
4037  {
4038  if (m_InputGateBias)
4039  {
4040  throw InvalidArgumentException(descriptorName + ": InputGateBias is present and CIFG-LSTM is enabled.");
4041  }
4042  }
4043  else
4044  {
4045  if (!m_InputGateBias)
4046  {
4047  throw InvalidArgumentException(descriptorName + ": If CIFG-LSTM is disabled InputGateBias "
4048  "must be present.");
4049  }
4051  n_cell, "InputGateBias");
4052  }
4053 
4054  ValidatePointer(m_ForgetGateBias, "Null pointer check", "ForgetGateBias");
4055  ValidateTensorNumDimNumElem(m_ForgetGateBias->GetTensorInfo(), 1, n_cell, "ForgetGateBias");
4056 
4057  ValidatePointer(m_CellBias, "Null pointer check", "CellBias");
4058  ValidateTensorNumDimNumElem(m_CellBias->GetTensorInfo(), 1, n_cell, "CellBias");
4059 
4060  ValidatePointer(m_OutputGateBias, "Null pointer check", "OutputGateBias");
4061  ValidateTensorNumDimNumElem(m_OutputGateBias->GetTensorInfo(), 1, n_cell, "OutputGateBias");
4062 
4063  if (m_ProjectionWeights)
4064  {
4066  (n_cell * n_output), "ProjectionWeights");
4067  }
4068  if (m_ProjectionBias)
4069  {
4070  ValidateTensorNumDimNumElem(m_ProjectionBias->GetTensorInfo(), 1, n_output, "ProjectionBias");
4071  }
4072 
4073  // Making sure the projection tensors are consistent:
4074  // 1) If projection weight is not present, then projection bias should not be
4075  // present.
4076  // 2) If projection weight is present, then projection bias is optional.
4077  bool projecton_tensors_consistent = ((!m_ProjectionWeights && !m_ProjectionBias &&
4083  if (!projecton_tensors_consistent)
4084  {
4085  throw InvalidArgumentException(descriptorName + ": Projection tensors are inconsistent.");
4086  }
4087 
4088  // The four layer normalization weights either all have values or none of them have values. Additionally, if
4089  // CIFG is used, input layer normalization weights tensor is omitted and the other layer normalization weights
4090  // either all have values or none of them have values. Layer normalization is used when the values of all the
4091  // layer normalization weights are present
4093  {
4094  ValidateTensorNumDimNumElem(m_InputLayerNormWeights->GetTensorInfo(), 1, n_cell, "InputLayerNormWeights");
4095  }
4097  {
4098  ValidateTensorNumDimNumElem(m_ForgetLayerNormWeights->GetTensorInfo(), 1, n_cell, "ForgetLayerNormWeights");
4099  }
4101  {
4102  ValidateTensorNumDimNumElem(m_CellLayerNormWeights->GetTensorInfo(), 1, n_cell, "CellLayerNormWeights");
4103  }
4105  {
4106  ValidateTensorNumDimNumElem(m_OutputLayerNormWeights->GetTensorInfo(), 1, n_cell, "OutputLayerNormWeights");
4107  }
4108 
4110  {
4112  {
4114  {
4115  throw InvalidArgumentException(descriptorName + ": Layer normalisation is enabled and CIFG-LSTM is "
4116  "disabled but InputLayerNormWeights are not present");
4117  }
4119  1, n_cell, "InputLayerNormWeights");
4120  }
4121  else if (m_InputLayerNormWeights)
4122  {
4123  throw InvalidArgumentException(descriptorName + ":InputLayerNormWeights are present while CIFG is "
4124  "enabled");
4125  }
4126 
4127  ValidatePointer(m_ForgetLayerNormWeights, "Null pointer check layer normalisation enabled",
4128  "ForgetLayerNormWeights");
4129  ValidateTensorNumDimNumElem(m_ForgetLayerNormWeights->GetTensorInfo(), 1, n_cell, "ForgetLayerNormWeights");
4130 
4131  ValidatePointer(m_OutputLayerNormWeights, "Null pointer check layer normalisation enabled",
4132  "OutputLayerNormWeights");
4133  ValidateTensorNumDimNumElem(m_OutputLayerNormWeights->GetTensorInfo(), 1, n_cell, "OutputLayerNormWeights");
4134 
4135  ValidatePointer(m_CellLayerNormWeights, "Null pointer check layer normalisation enabled",
4136  "CellLayerNormWeights");
4137  ValidateTensorNumDimNumElem(m_CellLayerNormWeights->GetTensorInfo(), 1, n_cell, "CellLayerNormWeights");
4138  }
4140  {
4141  throw InvalidArgumentException(descriptorName + ": Layer normalisation is disabled but one or more layer "
4142  "normalisation weights are present.");
4143  }
4144 }
bool m_ProjectionEnabled
Enable/disable the projection layer.
float m_ClippingThresProj
Clipping threshold value for the projection.
void ValidateTensorNumDimNumElem(const TensorInfo &tensorInfo, unsigned int numDimension, unsigned int numElements, std::string const &tensorName) const
TensorShape GetShape() const override
Get the number of elements for each dimension ordered from slowest iterating dimension to fastest ite...
bool m_TimeMajor
Enable/disable time major.
const TensorInfo & GetTensorInfo() const
std::vector< TensorInfo > m_InputTensorInfos
bool m_PeepholeEnabled
Enable/disable peephole.
std::vector< TensorInfo > m_OutputTensorInfos
float m_ClippingThresCell
Clipping threshold value for the cell state.
bool m_CifgEnabled
Enable/disable cifg (coupled input & forget gate).
bool m_LayerNormEnabled
Enable/disable layer normalization.
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_RecurrentToForgetWeights

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: