ArmNN
 20.02
SliceQueueDescriptor Struct Reference

#include <WorkloadData.hpp>

Inheritance diagram for SliceQueueDescriptor:
QueueDescriptorWithParameters< SliceDescriptor > 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< SliceDescriptor >
SliceDescriptor m_Parameters
 
- Public Attributes inherited from QueueDescriptor
std::vector< ITensorHandle * > m_Inputs
 
std::vector< ITensorHandle * > m_Outputs
 
- Protected Member Functions inherited from QueueDescriptorWithParameters< SliceDescriptor >
 ~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 554 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 2950 of file WorkloadData.cpp.

References TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), WorkloadInfo::m_InputTensorInfos, and WorkloadInfo::m_OutputTensorInfos.

2951 {
2952  const std::string descriptorName{"SliceQueueDescriptor"};
2953 
2954  ValidateNumInputs(workloadInfo, descriptorName, 1);
2955  ValidateNumOutputs(workloadInfo, descriptorName, 1);
2956 
2957  const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
2958  const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
2959 
2960  ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
2961 
2962  const unsigned int rank = inputTensorInfo.GetNumDimensions();
2963  if (rank > 4)
2964  {
2965  throw InvalidArgumentException(descriptorName + ": Input tensors with rank greater than 4 are not supported.");
2966  }
2967 
2968  ValidateTensorNumDimensions(outputTensorInfo, descriptorName, rank, "output");
2969 
2970  // Check if m_Begin and m_Size have the expected length
2971  if (m_Parameters.m_Begin.size() != rank)
2972  {
2973  throw InvalidArgumentException(descriptorName +
2974  ": Length of begin offset descriptor must equal rank " + std::to_string(rank));
2975  }
2976  if (m_Parameters.m_Size.size() != rank)
2977  {
2978  throw InvalidArgumentException(descriptorName +
2979  ": Length of size descriptor must equal rank " + std::to_string(rank));
2980  }
2981 
2982  // Check if the shape of the output tensor matches m_Size
2983  const TensorShape& outputShape = outputTensorInfo.GetShape();
2984  for (unsigned int i = 0u; i < rank; ++i)
2985  {
2986  if (m_Parameters.m_Size[i] != outputShape[i])
2987  {
2988  throw InvalidArgumentException(descriptorName + ": Size descriptor does not match output tensor.");
2989  }
2990  }
2991 
2992  // Check if the sum of begin offset and size in a given dimension
2993  // does not exceed the size of corresponding input
2994  const TensorShape& inputShape = inputTensorInfo.GetShape();
2995  for(unsigned int i = 0u; i < rank; ++i)
2996  {
2997  if (m_Parameters.m_Begin[i] + m_Parameters.m_Size[i] > inputShape[i])
2998  {
2999  throw InvalidArgumentException(descriptorName + ": Sum of begin offset and size for dimension " +
3000  std::to_string(i) + " exceeds input size.");
3001  }
3002  }
3003 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
std::vector< unsigned int > m_Size
Size of the slice in each dimension.
std::vector< TensorInfo > m_InputTensorInfos
std::vector< unsigned int > m_Begin
Beginning indices of the slice in each dimension.
std::vector< TensorInfo > m_OutputTensorInfos
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:92

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