ArmNN
 22.11
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 723 of file WorkloadData.hpp.

Constructor & Destructor Documentation

◆ UnidirectionalSequenceLstmQueueDescriptor()

Definition at line 725 of file WorkloadData.hpp.

726  : m_InputToInputWeights(nullptr)
727  , m_InputToForgetWeights(nullptr)
728  , m_InputToCellWeights(nullptr)
729  , m_InputToOutputWeights(nullptr)
730  , m_RecurrentToInputWeights(nullptr)
731  , m_RecurrentToForgetWeights(nullptr)
732  , m_RecurrentToCellWeights(nullptr)
733  , m_RecurrentToOutputWeights(nullptr)
734  , m_CellToInputWeights(nullptr)
735  , m_CellToForgetWeights(nullptr)
736  , m_CellToOutputWeights(nullptr)
737  , m_InputGateBias(nullptr)
738  , m_ForgetGateBias(nullptr)
739  , m_CellBias(nullptr)
740  , m_OutputGateBias(nullptr)
741  , m_ProjectionWeights(nullptr)
742  , m_ProjectionBias(nullptr)
743  , m_InputLayerNormWeights(nullptr)
744  , m_ForgetLayerNormWeights(nullptr)
745  , m_CellLayerNormWeights(nullptr)
746  , m_OutputLayerNormWeights(nullptr)
747  {
748  }
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_RecurrentToForgetWeights

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 3846 of file WorkloadData.cpp.

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

3847 {
3848  // Modified from LstmQueueDescriptor::Validate to support UnidirectionalSequenceLstm
3849 
3850  const std::string descriptorName{"UnidirectionalSequenceLstmQueueDescriptor"};
3851 
3852  // check dimensions of all inputs and outputs
3853  if (workloadInfo.m_InputTensorInfos.size() != 3)
3854  {
3855  throw InvalidArgumentException(descriptorName + ": Invalid number of inputs.");
3856  }
3857  if (workloadInfo.m_OutputTensorInfos.size() != 3)
3858  {
3859  throw InvalidArgumentException(descriptorName + ": Invalid number of outputs.");
3860  }
3861 
3862  std::vector<DataType> supportedTypes =
3863  {
3866  };
3867 
3868  // check for supported type of one input and match them with all the other input and output
3869  ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], supportedTypes, descriptorName);
3870 
3871  // Making sure clipping parameters have valid values.
3872  // == 0 means no clipping
3873  // > 0 means clipping
3874  if (m_Parameters.m_ClippingThresCell < 0.0f)
3875  {
3876  throw InvalidArgumentException(descriptorName + ": negative cell clipping threshold is invalid");
3877  }
3878  if (m_Parameters.m_ClippingThresProj < 0.0f)
3879  {
3880  throw InvalidArgumentException(descriptorName + ": negative projection clipping threshold is invalid");
3881  }
3882 
3883  unsigned int batchIndx = 0;
3884  unsigned int inputIndx = 1;
3885  uint32_t timeStep = 1;
3886  unsigned int timeIndx = 1;
3887  inputIndx = 2;
3889  {
3890  batchIndx = 1;
3891  timeIndx = 0;
3892 
3893  }
3894  timeStep = workloadInfo.m_InputTensorInfos[0].GetShape()[timeIndx];
3895 
3896  // Inferring batch size, number of outputs and number of cells from the inputs.
3897  const uint32_t n_input = workloadInfo.m_InputTensorInfos[0].GetShape()[inputIndx];
3898  const uint32_t n_batch = workloadInfo.m_InputTensorInfos[0].GetShape()[batchIndx];
3899  ValidatePointer(m_InputToOutputWeights, "Null pointer check", "InputToOutputWeights");
3900  const uint32_t n_cell = m_InputToOutputWeights->GetShape()[0];
3901  ValidatePointer(m_RecurrentToOutputWeights, "Null pointer check", "RecurrentToOutputWeights");
3902  const uint32_t n_output = m_RecurrentToOutputWeights->GetShape()[1];
3903 
3904  // input tensor
3905  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[0], 3, (timeStep * n_batch * n_input),
3906  descriptorName + " input_0");
3907  // outputStateInTensor
3908  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[1], 2, (n_batch * n_output),
3909  descriptorName + " input_1");
3910  // outputStateInTensor
3911  ValidateTensorNumDimNumElem(workloadInfo.m_InputTensorInfos[2], 2, (n_batch * n_cell),
3912  descriptorName + " input_2");
3913 
3914  // outputTensor
3915  ValidateTensorNumDimNumElem(workloadInfo.m_OutputTensorInfos[2], 3, (timeStep * n_batch * n_output),
3916  descriptorName + " output_0");
3917 
3918  // check that dimensions of inputs/outputs and QueueDescriptor data match with each other
3919  if ( m_InputToInputWeights )
3920  {
3922  (n_cell * n_input), "InputLayerNormWeights");
3923  }
3924 
3925  ValidatePointer(m_InputToForgetWeights, "Null pointer check", "InputToForgetWeights");
3927  (n_cell * n_input), "InputToForgetWeights");
3928 
3929  ValidatePointer(m_InputToCellWeights, "Null pointer check", "InputToCellWeights");
3931  (n_cell * n_input), "InputToCellWeights");
3932 
3934  {
3936  (n_cell * n_output), "RecurrentToInputWeights");
3937  }
3938 
3939  ValidatePointer(m_RecurrentToForgetWeights, "Null pointer check", "RecurrentToForgetWeights");
3941  (n_cell * n_output), "RecurrentToForgetWeights");
3942 
3943  ValidatePointer(m_RecurrentToCellWeights, "Null pointer check", "RecurrentToCellWeights");
3945  (n_cell * n_output), "RecurrentToCellWeights");
3946 
3947  // Make sure the input-gate's parameters are either both present (regular
3948  // LSTM) or not at all (CIFG-LSTM). And CifgEnable is set accordingly.
3949  bool cifg_weights_all_or_none = ((m_InputToInputWeights && m_RecurrentToInputWeights &&
3953  if (!cifg_weights_all_or_none)
3954  {
3955  throw InvalidArgumentException(descriptorName + ": Input-Gate's parameters InputToInputWeights and "
3956  "RecurrentToInputWeights must either both be present (regular LSTM) "
3957  "or both not present (CIFG-LSTM). In addition CifgEnable must be set "
3958  "accordingly.");
3959  }
3960 
3961  if ( m_CellToInputWeights )
3962  {
3964  n_cell, "CellToInputWeights");
3965  }
3966  if ( m_CellToForgetWeights )
3967  {
3969  n_cell, "CellToForgetWeights");
3970  }
3971  if ( m_CellToOutputWeights )
3972  {
3974  n_cell, "CellToOutputWeights");
3975  }
3976 
3977  // Making sure the peephole weights are there all or none. And PeepholeEnable is set accordingly.
3978  bool peephole_weights_all_or_none =
3983  if (!peephole_weights_all_or_none)
3984  {
3985  throw InvalidArgumentException(descriptorName + ": Invalid combination of peephole parameters.");
3986  }
3987 
3988  // Make sure the input gate bias is present only when not a CIFG-LSTM.
3990  {
3991  if (m_InputGateBias)
3992  {
3993  throw InvalidArgumentException(descriptorName + ": InputGateBias is present and CIFG-LSTM is enabled.");
3994  }
3995  }
3996  else
3997  {
3998  if (!m_InputGateBias)
3999  {
4000  throw InvalidArgumentException(descriptorName + ": If CIFG-LSTM is disabled InputGateBias "
4001  "must be present.");
4002  }
4004  n_cell, "InputGateBias");
4005  }
4006 
4007  ValidatePointer(m_ForgetGateBias, "Null pointer check", "ForgetGateBias");
4008  ValidateTensorNumDimNumElem(m_ForgetGateBias->GetTensorInfo(), 1, n_cell, "ForgetGateBias");
4009 
4010  ValidatePointer(m_CellBias, "Null pointer check", "CellBias");
4011  ValidateTensorNumDimNumElem(m_CellBias->GetTensorInfo(), 1, n_cell, "CellBias");
4012 
4013  ValidatePointer(m_OutputGateBias, "Null pointer check", "OutputGateBias");
4014  ValidateTensorNumDimNumElem(m_OutputGateBias->GetTensorInfo(), 1, n_cell, "OutputGateBias");
4015 
4016  if (m_ProjectionWeights)
4017  {
4019  (n_cell * n_output), "ProjectionWeights");
4020  }
4021  if (m_ProjectionBias)
4022  {
4023  ValidateTensorNumDimNumElem(m_ProjectionBias->GetTensorInfo(), 1, n_output, "ProjectionBias");
4024  }
4025 
4026  // Making sure the projection tensors are consistent:
4027  // 1) If projection weight is not present, then projection bias should not be
4028  // present.
4029  // 2) If projection weight is present, then projection bias is optional.
4030  bool projecton_tensors_consistent = ((!m_ProjectionWeights && !m_ProjectionBias &&
4036  if (!projecton_tensors_consistent)
4037  {
4038  throw InvalidArgumentException(descriptorName + ": Projection tensors are inconsistent.");
4039  }
4040 
4041  // The four layer normalization weights either all have values or none of them have values. Additionally, if
4042  // CIFG is used, input layer normalization weights tensor is omitted and the other layer normalization weights
4043  // either all have values or none of them have values. Layer normalization is used when the values of all the
4044  // layer normalization weights are present
4046  {
4047  ValidateTensorNumDimNumElem(m_InputLayerNormWeights->GetTensorInfo(), 1, n_cell, "InputLayerNormWeights");
4048  }
4050  {
4051  ValidateTensorNumDimNumElem(m_ForgetLayerNormWeights->GetTensorInfo(), 1, n_cell, "ForgetLayerNormWeights");
4052  }
4054  {
4055  ValidateTensorNumDimNumElem(m_CellLayerNormWeights->GetTensorInfo(), 1, n_cell, "CellLayerNormWeights");
4056  }
4058  {
4059  ValidateTensorNumDimNumElem(m_OutputLayerNormWeights->GetTensorInfo(), 1, n_cell, "OutputLayerNormWeights");
4060  }
4061 
4063  {
4065  {
4067  {
4068  throw InvalidArgumentException(descriptorName + ": Layer normalisation is enabled and CIFG-LSTM is "
4069  "disabled but InputLayerNormWeights are not present");
4070  }
4072  1, n_cell, "InputLayerNormWeights");
4073  }
4074  else if (m_InputLayerNormWeights)
4075  {
4076  throw InvalidArgumentException(descriptorName + ":InputLayerNormWeights are present while CIFG is "
4077  "enabled");
4078  }
4079 
4080  ValidatePointer(m_ForgetLayerNormWeights, "Null pointer check layer normalisation enabled",
4081  "ForgetLayerNormWeights");
4082  ValidateTensorNumDimNumElem(m_ForgetLayerNormWeights->GetTensorInfo(), 1, n_cell, "ForgetLayerNormWeights");
4083 
4084  ValidatePointer(m_OutputLayerNormWeights, "Null pointer check layer normalisation enabled",
4085  "OutputLayerNormWeights");
4086  ValidateTensorNumDimNumElem(m_OutputLayerNormWeights->GetTensorInfo(), 1, n_cell, "OutputLayerNormWeights");
4087 
4088  ValidatePointer(m_CellLayerNormWeights, "Null pointer check layer normalisation enabled",
4089  "CellLayerNormWeights");
4090  ValidateTensorNumDimNumElem(m_CellLayerNormWeights->GetTensorInfo(), 1, n_cell, "CellLayerNormWeights");
4091  }
4093  {
4094  throw InvalidArgumentException(descriptorName + ": Layer normalisation is disabled but one or more layer "
4095  "normalisation weights are present.");
4096  }
4097 }
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

const ConstTensorHandle* m_CellBias

Definition at line 763 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_CellLayerNormWeights

const ConstTensorHandle* m_CellLayerNormWeights

Definition at line 769 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_CellToForgetWeights

const ConstTensorHandle* m_CellToForgetWeights

Definition at line 759 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_CellToInputWeights

const ConstTensorHandle* m_CellToInputWeights

Definition at line 758 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_CellToOutputWeights

const ConstTensorHandle* m_CellToOutputWeights

Definition at line 760 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_ForgetGateBias

const ConstTensorHandle* m_ForgetGateBias

Definition at line 762 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_ForgetLayerNormWeights

const ConstTensorHandle* m_ForgetLayerNormWeights

Definition at line 768 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_InputGateBias

const ConstTensorHandle* m_InputGateBias

Definition at line 761 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_InputLayerNormWeights

const ConstTensorHandle* m_InputLayerNormWeights

Definition at line 767 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_InputToCellWeights

const ConstTensorHandle* m_InputToCellWeights

Definition at line 752 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_InputToForgetWeights

const ConstTensorHandle* m_InputToForgetWeights

Definition at line 751 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_InputToInputWeights

const ConstTensorHandle* m_InputToInputWeights

Definition at line 750 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_InputToOutputWeights

const ConstTensorHandle* m_InputToOutputWeights

Definition at line 753 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_OutputGateBias

const ConstTensorHandle* m_OutputGateBias

Definition at line 764 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_OutputLayerNormWeights

const ConstTensorHandle* m_OutputLayerNormWeights

Definition at line 770 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_ProjectionBias

const ConstTensorHandle* m_ProjectionBias

Definition at line 766 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_ProjectionWeights

const ConstTensorHandle* m_ProjectionWeights

Definition at line 765 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_RecurrentToCellWeights

const ConstTensorHandle* m_RecurrentToCellWeights

Definition at line 756 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_RecurrentToForgetWeights

const ConstTensorHandle* m_RecurrentToForgetWeights

Definition at line 755 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_RecurrentToInputWeights

const ConstTensorHandle* m_RecurrentToInputWeights

Definition at line 754 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().

◆ m_RecurrentToOutputWeights

const ConstTensorHandle* m_RecurrentToOutputWeights

Definition at line 757 of file WorkloadData.hpp.

Referenced by UnidirectionalSequenceLstmLayer::CreateWorkload().


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