ArmNN
 24.08
SliceQueueDescriptor Struct Reference

#include <WorkloadData.hpp>

Inheritance diagram for SliceQueueDescriptor:
[legend]
Collaboration diagram for SliceQueueDescriptor:
[legend]

Public Member Functions

void Validate (const WorkloadInfo &workloadInfo) const
 
- Public Member Functions inherited from QueueDescriptorWithParameters< SliceDescriptor >
virtual ~QueueDescriptorWithParameters ()=default
 
- Public Member Functions inherited from QueueDescriptor
virtual ~QueueDescriptor ()=default
 
void ValidateTensorNumDimensions (const TensorInfo &tensor, std::string const &descName, unsigned int numDimensions, std::string const &tensorName) const
 
void ValidateTensorNumDimNumElem (const TensorInfo &tensorInfo, unsigned int numDimension, unsigned int numElements, std::string const &tensorName) const
 
void ValidateInputsOutputs (const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
 
template<typename T >
const T * GetAdditionalInformation () 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
 
void * m_AdditionalInfoObject
 
bool m_AllowExpandedDims = false
 
- Protected Member Functions inherited from QueueDescriptorWithParameters< SliceDescriptor >
 QueueDescriptorWithParameters ()=default
 
 QueueDescriptorWithParameters (QueueDescriptorWithParameters const &)=default
 
QueueDescriptorWithParametersoperator= (QueueDescriptorWithParameters const &)=default
 
- Protected Member Functions inherited from QueueDescriptor
 QueueDescriptor ()
 
 QueueDescriptor (QueueDescriptor const &)=default
 
QueueDescriptoroperator= (QueueDescriptor const &)=default
 

Detailed Description

Definition at line 656 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 3634 of file WorkloadData.cpp.

3635 {
3636  const std::string descriptorName{"SliceQueueDescriptor"};
3637 
3638  ValidateNumInputs(workloadInfo, descriptorName, 1);
3639  ValidateNumOutputs(workloadInfo, descriptorName, 1);
3640 
3641  const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
3642  const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
3643 
3644  ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
3645 
3646  const unsigned int rank = inputTensorInfo.GetNumDimensions();
3647  if (rank > 5)
3648  {
3649  throw InvalidArgumentException(descriptorName + ": Input tensors with rank greater than 5 are not supported.");
3650  }
3651 
3652  ValidateTensorNumDimensions(outputTensorInfo, descriptorName, rank, "output");
3653 
3654  // Check if m_Begin and m_Size have the expected length
3655  if (m_Parameters.m_Begin.size() != rank)
3656  {
3657  throw InvalidArgumentException(descriptorName +
3658  ": Length of begin offset descriptor must equal rank " + std::to_string(rank));
3659  }
3660  if (m_Parameters.m_Size.size() != rank)
3661  {
3662  throw InvalidArgumentException(descriptorName +
3663  ": Length of size descriptor must equal rank " + std::to_string(rank));
3664  }
3665 
3666  // Check if the shape of the output tensor matches m_Size
3667  const TensorShape& outputShape = outputTensorInfo.GetShape();
3668  for (unsigned int i = 0u; i < rank; ++i)
3669  {
3670  if (m_Parameters.m_Size[i] != outputShape[i])
3671  {
3672  throw InvalidArgumentException(descriptorName + ": Size descriptor does not match output tensor.");
3673  }
3674  }
3675 
3676  // Check if the sum of begin offset and size in a given dimension
3677  // does not exceed the size of corresponding input
3678  const TensorShape& inputShape = inputTensorInfo.GetShape();
3679  for(unsigned int i = 0u; i < rank; ++i)
3680  {
3681  if (m_Parameters.m_Begin[i] + m_Parameters.m_Size[i] > inputShape[i])
3682  {
3683  throw InvalidArgumentException(descriptorName + ": Sum of begin offset and size for dimension " +
3684  std::to_string(i) + " exceeds input size.");
3685  }
3686  }
3687 }

References TensorInfo::GetNumDimensions(), TensorInfo::GetShape(), SliceDescriptor::m_Begin, WorkloadInfo::m_InputTensorInfos, WorkloadInfo::m_OutputTensorInfos, QueueDescriptorWithParameters< SliceDescriptor >::m_Parameters, SliceDescriptor::m_Size, and QueueDescriptor::ValidateTensorNumDimensions().


The documentation for this struct was generated from the following files:
armnn::SliceDescriptor::m_Begin
std::vector< unsigned int > m_Begin
Beginning indices of the slice in each dimension.
Definition: Descriptors.hpp:1244
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::TensorInfo::GetNumDimensions
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:197
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::WorkloadInfo::m_OutputTensorInfos
std::vector< TensorInfo > m_OutputTensorInfos
Definition: WorkloadInfo.hpp:19
armnn::QueueDescriptorWithParameters< SliceDescriptor >::m_Parameters
SliceDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::InvalidArgumentException
Definition: Exceptions.hpp:80
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:193
armnn::WorkloadInfo::m_InputTensorInfos
std::vector< TensorInfo > m_InputTensorInfos
Definition: WorkloadInfo.hpp:18
armnn::QueueDescriptor::ValidateTensorNumDimensions
void ValidateTensorNumDimensions(const TensorInfo &tensor, std::string const &descName, unsigned int numDimensions, std::string const &tensorName) const
Definition: WorkloadData.cpp:398
armnn::SliceDescriptor::m_Size
std::vector< unsigned int > m_Size
Size of the slice in each dimension.
Definition: Descriptors.hpp:1247