ArmNN
 24.02
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 914 of file WorkloadData.cpp.

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

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