ArmNN
 24.08
StackQueueDescriptor Struct Reference

#include <WorkloadData.hpp>

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

Public Member Functions

void Validate (const WorkloadInfo &workloadInfo) const
 
- Public Member Functions inherited from QueueDescriptorWithParameters< StackDescriptor >
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
 

Additional Inherited Members

- Public Attributes inherited from QueueDescriptorWithParameters< StackDescriptor >
StackDescriptor m_Parameters
 
- Public Attributes inherited from QueueDescriptor
std::vector< ITensorHandle * > m_Inputs
 
std::vector< ITensorHandle * > m_Outputs
 
void * m_AdditionalInfoObject
 
bool m_AllowExpandedDims = false
 
- Protected Member Functions inherited from QueueDescriptorWithParameters< StackDescriptor >
 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 152 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 916 of file WorkloadData.cpp.

917 {
918  const std::string descriptorName{"StackQueueDescriptor"};
919 
920  ValidateNumOutputs(workloadInfo, descriptorName, 1);
921 
922  if (m_Parameters.m_NumInputs != workloadInfo.m_InputTensorInfos.size())
923  {
924  throw InvalidArgumentException(descriptorName + ": Must have the defined number of input tensors.");
925  }
926 
927  // All inputs must have the same shape, which is defined in parameters
928  const TensorShape& inputShape = m_Parameters.m_InputShape;
929  for (unsigned int i = 0; i < workloadInfo.m_InputTensorInfos.size(); ++i)
930  {
931  if (workloadInfo.m_InputTensorInfos[i].GetShape() != inputShape)
932  {
933  throw InvalidArgumentException(descriptorName + ": All input tensor shapes must match the defined shape.");
934  }
935  }
936 
937  if (inputShape.GetNumDimensions() > 4)
938  {
939  throw InvalidArgumentException(descriptorName + ": Input tensor may have up to 4 dimensions.");
940  }
941 
942  // m_Axis is 0-based and may take values from 0 to the number of input dimensions (inclusive),
943  // since the output tensor has an additional dimension.
944  if (m_Parameters.m_Axis > inputShape.GetNumDimensions())
945  {
946  throw InvalidArgumentException(descriptorName + ": Axis may not be greater "
947  "than the number of input dimensions.");
948  }
949 
950  // Output shape must be as inferred from the input shape
951  const TensorShape& outputShape = workloadInfo.m_OutputTensorInfos[0].GetShape();
952  for (unsigned int i = 0; i < m_Parameters.m_Axis; ++i)
953  {
954  if (outputShape[i] != inputShape[i])
955  {
956  throw InvalidArgumentException(descriptorName + ": Output tensor must "
957  "match shape inferred from input tensor.");
958  }
959  }
960 
961  if (outputShape[m_Parameters.m_Axis] != m_Parameters.m_NumInputs)
962  {
963  throw InvalidArgumentException(descriptorName + ": Output tensor must "
964  "match shape inferred from input tensor.");
965  }
966 
967  for (unsigned int i = m_Parameters.m_Axis + 1; i < inputShape.GetNumDimensions() + 1; ++i)
968  {
969  if (outputShape[i] != inputShape[i-1])
970  {
971  throw InvalidArgumentException(descriptorName + ": Output tensor must "
972  "match shape inferred from input tensor.");
973  }
974  }
975 
976  if (outputShape.GetNumDimensions() > 5)
977  {
978  throw InvalidArgumentException(descriptorName + ": Output tensor may have up to 5 dimensions.");
979  }
980 
981  // Check the supported data types
982  std::vector<DataType> supportedTypes =
983  {
992  };
993 
994  ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], supportedTypes, descriptorName);
995 
996  for (unsigned int i = 1ul; i < workloadInfo.m_InputTensorInfos.size(); ++i)
997  {
998  ValidateTensorDataTypesMatch(workloadInfo.m_InputTensorInfos[0],
999  workloadInfo.m_InputTensorInfos[i],
1000  descriptorName,
1001  "input_0",
1002  "input_" + std::to_string(i));
1003  }
1004 
1005  ValidateTensorDataTypesMatch(workloadInfo.m_InputTensorInfos[0],
1006  workloadInfo.m_OutputTensorInfos[0],
1007  descriptorName,
1008  "input_0",
1009  "output");
1010 }

References armnn::BFloat16, armnn::Boolean, armnn::Float16, armnn::Float32, TensorShape::GetNumDimensions(), StackDescriptor::m_Axis, StackDescriptor::m_InputShape, WorkloadInfo::m_InputTensorInfos, StackDescriptor::m_NumInputs, WorkloadInfo::m_OutputTensorInfos, QueueDescriptorWithParameters< StackDescriptor >::m_Parameters, armnn::QAsymmS8, armnn::QAsymmU8, armnn::QSymmS16, and armnn::Signed32.


The documentation for this struct was generated from the following files:
armnn::DataType::Boolean
@ Boolean
armnn::DataType::Float32
@ Float32
armnn::DataType::QAsymmU8
@ QAsymmU8
armnn::DataType::QSymmS16
@ QSymmS16
armnn::DataType::BFloat16
@ BFloat16
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::StackDescriptor::m_NumInputs
uint32_t m_NumInputs
Number of input tensors.
Definition: Descriptors.hpp:1275
armnn::DataType::Float16
@ Float16
armnn::WorkloadInfo::m_OutputTensorInfos
std::vector< TensorInfo > m_OutputTensorInfos
Definition: WorkloadInfo.hpp:19
armnn::QueueDescriptorWithParameters< StackDescriptor >::m_Parameters
StackDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::TensorShape::GetNumDimensions
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
armnn::StackDescriptor::m_Axis
uint32_t m_Axis
0-based axis along which to stack the input tensors.
Definition: Descriptors.hpp:1273
armnn::InvalidArgumentException
Definition: Exceptions.hpp:80
armnn::StackDescriptor::m_InputShape
TensorShape m_InputShape
Required shape of all input tensors.
Definition: Descriptors.hpp:1277
armnn::DataType::Signed32
@ Signed32
armnn::DataType::QAsymmS8
@ QAsymmS8
armnn::WorkloadInfo::m_InputTensorInfos
std::vector< TensorInfo > m_InputTensorInfos
Definition: WorkloadInfo.hpp:18