ArmNN
 20.05
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 617 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 3331 of file WorkloadData.cpp.

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

3332 {
3333  const std::string descriptorName{"SliceQueueDescriptor"};
3334 
3335  ValidateNumInputs(workloadInfo, descriptorName, 1);
3336  ValidateNumOutputs(workloadInfo, descriptorName, 1);
3337 
3338  const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
3339  const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
3340 
3341  ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
3342 
3343  const unsigned int rank = inputTensorInfo.GetNumDimensions();
3344  if (rank > 4)
3345  {
3346  throw InvalidArgumentException(descriptorName + ": Input tensors with rank greater than 4 are not supported.");
3347  }
3348 
3349  ValidateTensorNumDimensions(outputTensorInfo, descriptorName, rank, "output");
3350 
3351  // Check if m_Begin and m_Size have the expected length
3352  if (m_Parameters.m_Begin.size() != rank)
3353  {
3354  throw InvalidArgumentException(descriptorName +
3355  ": Length of begin offset descriptor must equal rank " + std::to_string(rank));
3356  }
3357  if (m_Parameters.m_Size.size() != rank)
3358  {
3359  throw InvalidArgumentException(descriptorName +
3360  ": Length of size descriptor must equal rank " + std::to_string(rank));
3361  }
3362 
3363  // Check if the shape of the output tensor matches m_Size
3364  const TensorShape& outputShape = outputTensorInfo.GetShape();
3365  for (unsigned int i = 0u; i < rank; ++i)
3366  {
3367  if (m_Parameters.m_Size[i] != outputShape[i])
3368  {
3369  throw InvalidArgumentException(descriptorName + ": Size descriptor does not match output tensor.");
3370  }
3371  }
3372 
3373  // Check if the sum of begin offset and size in a given dimension
3374  // does not exceed the size of corresponding input
3375  const TensorShape& inputShape = inputTensorInfo.GetShape();
3376  for(unsigned int i = 0u; i < rank; ++i)
3377  {
3378  if (m_Parameters.m_Begin[i] + m_Parameters.m_Size[i] > inputShape[i])
3379  {
3380  throw InvalidArgumentException(descriptorName + ": Sum of begin offset and size for dimension " +
3381  std::to_string(i) + " exceeds input size.");
3382  }
3383  }
3384 }
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: