ArmNN  NotReleased
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 864 of file WorkloadData.cpp.

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

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

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