ArmNN
 20.02
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
 

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
 
- 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 ()=default
 
 QueueDescriptor (QueueDescriptor const &)=default
 
QueueDescriptoroperator= (QueueDescriptor const &)=default
 

Detailed Description

Definition at line 124 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 871 of file WorkloadData.cpp.

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

872 {
873  const std::string descriptorName{"StackQueueDescriptor"};
874 
875  ValidateNumOutputs(workloadInfo, descriptorName, 1);
876 
877  if (m_Parameters.m_NumInputs != workloadInfo.m_InputTensorInfos.size())
878  {
879  throw InvalidArgumentException(descriptorName + ": Must have the defined number of input tensors.");
880  }
881 
882  // All inputs must have the same shape, which is defined in parameters
883  const TensorShape& inputShape = m_Parameters.m_InputShape;
884  for (unsigned int i = 0; i < workloadInfo.m_InputTensorInfos.size(); ++i)
885  {
886  if (workloadInfo.m_InputTensorInfos[i].GetShape() != inputShape)
887  {
888  throw InvalidArgumentException(descriptorName + ": All input tensor shapes must match the defined shape.");
889  }
890  }
891 
892  if (inputShape.GetNumDimensions() > 4)
893  {
894  throw InvalidArgumentException(descriptorName + ": Input tensor may have up to 4 dimensions.");
895  }
896 
897  // m_Axis is 0-based and may take values from 0 to the number of input dimensions (inclusive),
898  // since the output tensor has an additional dimension.
899  if (m_Parameters.m_Axis > inputShape.GetNumDimensions())
900  {
901  throw InvalidArgumentException(descriptorName + ": Axis may not be greater "
902  "than the number of input dimensions.");
903  }
904 
905  // Output shape must be as inferred from the input shape
906  const TensorShape& outputShape = workloadInfo.m_OutputTensorInfos[0].GetShape();
907  for (unsigned int i = 0; i < m_Parameters.m_Axis; ++i)
908  {
909  if (outputShape[i] != inputShape[i])
910  {
911  throw InvalidArgumentException(descriptorName + ": Output tensor must "
912  "match shape inferred from input tensor.");
913  }
914  }
915 
916  if (outputShape[m_Parameters.m_Axis] != m_Parameters.m_NumInputs)
917  {
918  throw InvalidArgumentException(descriptorName + ": Output tensor must "
919  "match shape inferred from input tensor.");
920  }
921 
922  for (unsigned int i = m_Parameters.m_Axis + 1; i < inputShape.GetNumDimensions() + 1; ++i)
923  {
924  if (outputShape[i] != inputShape[i-1])
925  {
926  throw InvalidArgumentException(descriptorName + ": Output tensor must "
927  "match shape inferred from input tensor.");
928  }
929  }
930 
931  if (outputShape.GetNumDimensions() > 5)
932  {
933  throw InvalidArgumentException(descriptorName + ": Output tensor may have up to 5 dimensions.");
934  }
935 
936  // Check the supported data types
937  std::vector<DataType> supportedTypes =
938  {
946  };
947 
948  ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], supportedTypes, descriptorName);
949 
950  for (unsigned int i = 1ul; i < workloadInfo.m_InputTensorInfos.size(); ++i)
951  {
952  ValidateTensorDataTypesMatch(workloadInfo.m_InputTensorInfos[0],
953  workloadInfo.m_InputTensorInfos[i],
954  descriptorName,
955  "input_0",
956  "input_" + std::to_string(i));
957  }
958 
959  ValidateTensorDataTypesMatch(workloadInfo.m_InputTensorInfos[0],
960  workloadInfo.m_OutputTensorInfos[0],
961  descriptorName,
962  "input_0",
963  "output");
964 }
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
Definition: Tensor.hpp:43

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