ArmNN
 20.05
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 873 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.

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