ArmNN
 21.08
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 QueueDescriptor
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
 
- Protected Member Functions inherited from QueueDescriptorWithParameters< StackDescriptor >
 ~QueueDescriptorWithParameters ()=default
 
 QueueDescriptorWithParameters ()=default
 
 QueueDescriptorWithParameters (QueueDescriptorWithParameters const &)=default
 
QueueDescriptorWithParametersoperator= (QueueDescriptorWithParameters const &)=default
 
- Protected Member Functions inherited from QueueDescriptor
 ~QueueDescriptor ()=default
 
 QueueDescriptor ()
 
 QueueDescriptor (QueueDescriptor const &)=default
 
QueueDescriptoroperator= (QueueDescriptor const &)=default
 

Detailed Description

Definition at line 142 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 921 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.

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