ArmNN
 24.02
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 3630 of file WorkloadData.cpp.

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

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:397
armnn::SliceDescriptor::m_Size
std::vector< unsigned int > m_Size
Size of the slice in each dimension.
Definition: Descriptors.hpp:1247