ArmNN
 20.08
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 628 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 3359 of file WorkloadData.cpp.

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

3360 {
3361  const std::string descriptorName{"SliceQueueDescriptor"};
3362 
3363  ValidateNumInputs(workloadInfo, descriptorName, 1);
3364  ValidateNumOutputs(workloadInfo, descriptorName, 1);
3365 
3366  const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
3367  const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
3368 
3369  ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
3370 
3371  const unsigned int rank = inputTensorInfo.GetNumDimensions();
3372  if (rank > 4)
3373  {
3374  throw InvalidArgumentException(descriptorName + ": Input tensors with rank greater than 4 are not supported.");
3375  }
3376 
3377  ValidateTensorNumDimensions(outputTensorInfo, descriptorName, rank, "output");
3378 
3379  // Check if m_Begin and m_Size have the expected length
3380  if (m_Parameters.m_Begin.size() != rank)
3381  {
3382  throw InvalidArgumentException(descriptorName +
3383  ": Length of begin offset descriptor must equal rank " + std::to_string(rank));
3384  }
3385  if (m_Parameters.m_Size.size() != rank)
3386  {
3387  throw InvalidArgumentException(descriptorName +
3388  ": Length of size descriptor must equal rank " + std::to_string(rank));
3389  }
3390 
3391  // Check if the shape of the output tensor matches m_Size
3392  const TensorShape& outputShape = outputTensorInfo.GetShape();
3393  for (unsigned int i = 0u; i < rank; ++i)
3394  {
3395  if (m_Parameters.m_Size[i] != outputShape[i])
3396  {
3397  throw InvalidArgumentException(descriptorName + ": Size descriptor does not match output tensor.");
3398  }
3399  }
3400 
3401  // Check if the sum of begin offset and size in a given dimension
3402  // does not exceed the size of corresponding input
3403  const TensorShape& inputShape = inputTensorInfo.GetShape();
3404  for(unsigned int i = 0u; i < rank; ++i)
3405  {
3406  if (m_Parameters.m_Begin[i] + m_Parameters.m_Size[i] > inputShape[i])
3407  {
3408  throw InvalidArgumentException(descriptorName + ": Sum of begin offset and size for dimension " +
3409  std::to_string(i) + " exceeds input size.");
3410  }
3411  }
3412 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
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:191

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