ArmNN
 22.05.01
StackQueueDescriptor Struct Reference

#include <WorkloadData.hpp>

Inheritance diagram for StackQueueDescriptor:
QueueDescriptorWithParameters< StackDescriptor > QueueDescriptor

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 942 of file WorkloadData.cpp.

References armnn::BFloat16, armnn::Boolean, armnn::Float16, armnn::Float32, TensorShape::GetNumDimensions(), WorkloadInfo::m_InputTensorInfos, WorkloadInfo::m_OutputTensorInfos, armnn::QAsymmS8, armnn::QAsymmU8, armnn::QSymmS16, and armnn::Signed32.

943 {
944  const std::string descriptorName{"StackQueueDescriptor"};
945 
946  ValidateNumOutputs(workloadInfo, descriptorName, 1);
947 
948  if (m_Parameters.m_NumInputs != workloadInfo.m_InputTensorInfos.size())
949  {
950  throw InvalidArgumentException(descriptorName + ": Must have the defined number of input tensors.");
951  }
952 
953  // All inputs must have the same shape, which is defined in parameters
954  const TensorShape& inputShape = m_Parameters.m_InputShape;
955  for (unsigned int i = 0; i < workloadInfo.m_InputTensorInfos.size(); ++i)
956  {
957  if (workloadInfo.m_InputTensorInfos[i].GetShape() != inputShape)
958  {
959  throw InvalidArgumentException(descriptorName + ": All input tensor shapes must match the defined shape.");
960  }
961  }
962 
963  if (inputShape.GetNumDimensions() > 4)
964  {
965  throw InvalidArgumentException(descriptorName + ": Input tensor may have up to 4 dimensions.");
966  }
967 
968  // m_Axis is 0-based and may take values from 0 to the number of input dimensions (inclusive),
969  // since the output tensor has an additional dimension.
970  if (m_Parameters.m_Axis > inputShape.GetNumDimensions())
971  {
972  throw InvalidArgumentException(descriptorName + ": Axis may not be greater "
973  "than the number of input dimensions.");
974  }
975 
976  // Output shape must be as inferred from the input shape
977  const TensorShape& outputShape = workloadInfo.m_OutputTensorInfos[0].GetShape();
978  for (unsigned int i = 0; i < m_Parameters.m_Axis; ++i)
979  {
980  if (outputShape[i] != inputShape[i])
981  {
982  throw InvalidArgumentException(descriptorName + ": Output tensor must "
983  "match shape inferred from input tensor.");
984  }
985  }
986 
987  if (outputShape[m_Parameters.m_Axis] != m_Parameters.m_NumInputs)
988  {
989  throw InvalidArgumentException(descriptorName + ": Output tensor must "
990  "match shape inferred from input tensor.");
991  }
992 
993  for (unsigned int i = m_Parameters.m_Axis + 1; i < inputShape.GetNumDimensions() + 1; ++i)
994  {
995  if (outputShape[i] != inputShape[i-1])
996  {
997  throw InvalidArgumentException(descriptorName + ": Output tensor must "
998  "match shape inferred from input tensor.");
999  }
1000  }
1001 
1002  if (outputShape.GetNumDimensions() > 5)
1003  {
1004  throw InvalidArgumentException(descriptorName + ": Output tensor may have up to 5 dimensions.");
1005  }
1006 
1007  // Check the supported data types
1008  std::vector<DataType> supportedTypes =
1009  {
1018  };
1019 
1020  ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], supportedTypes, descriptorName);
1021 
1022  for (unsigned int i = 1ul; i < workloadInfo.m_InputTensorInfos.size(); ++i)
1023  {
1024  ValidateTensorDataTypesMatch(workloadInfo.m_InputTensorInfos[0],
1025  workloadInfo.m_InputTensorInfos[i],
1026  descriptorName,
1027  "input_0",
1028  "input_" + std::to_string(i));
1029  }
1030 
1031  ValidateTensorDataTypesMatch(workloadInfo.m_InputTensorInfos[0],
1032  workloadInfo.m_OutputTensorInfos[0],
1033  descriptorName,
1034  "input_0",
1035  "output");
1036 }
uint32_t m_Axis
0-based axis along which to stack the input tensors.
TensorShape m_InputShape
Required shape of all input tensors.
std::vector< TensorInfo > m_InputTensorInfos
std::vector< TensorInfo > m_OutputTensorInfos
uint32_t m_NumInputs
Number of input tensors.
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174

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