ArmNN
 24.02
BatchToSpaceNdQueueDescriptor Struct Reference

#include <WorkloadData.hpp>

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

Public Member Functions

void Validate (const WorkloadInfo &workloadInfo) const
 
- Public Member Functions inherited from QueueDescriptorWithParameters< BatchToSpaceNdDescriptor >
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< BatchToSpaceNdDescriptor >
BatchToSpaceNdDescriptor 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< BatchToSpaceNdDescriptor >
 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 462 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 2524 of file WorkloadData.cpp.

2525 {
2526  const std::string descriptorName{"BatchToSpaceNdQueueDescriptor"};
2527 
2528  ValidateNumInputs(workloadInfo, descriptorName, 1);
2529  ValidateNumOutputs(workloadInfo, descriptorName, 1);
2530 
2531  const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
2532  const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
2533 
2534  if (m_Parameters.m_BlockShape.size() != m_Parameters.m_Crops.size())
2535  {
2536  throw InvalidArgumentException(descriptorName + ": Crops must contain the same number of "
2537  "dimensions as Block Shape.");
2538  }
2539 
2540  if (m_Parameters.m_BlockShape.size() == 2)
2541  {
2542  ValidateTensorNumDimensions(inputTensorInfo, descriptorName, 4, "input");
2543  ValidateTensorNumDimensions(outputTensorInfo, descriptorName, 4, "output");
2544  }
2545  else if (m_Parameters.m_BlockShape.size() == 1)
2546  {
2547  ValidateTensorNumDimensions(inputTensorInfo, descriptorName, 3, "input");
2548  ValidateTensorNumDimensions(outputTensorInfo, descriptorName, 3, "output");
2549  }
2550  else
2551  {
2552  throw InvalidArgumentException(descriptorName + ": Invalid Block and Crops size.");
2553  }
2554 
2555  // In a 4D tensor, there will be 2 spatialDimensions (H and W), and the for loop will run twice.
2556  // In a 3D tensor, there will be 1 spatialDimensions, and the for loop will run once.
2557  unsigned int firstSpatialDimension = m_Parameters.m_DataLayout == DataLayout::NCHW ? 2 : 1;
2558  for (unsigned int i = 0; i < m_Parameters.m_BlockShape.size(); ++i)
2559  {
2560  unsigned int spatialDimension = firstSpatialDimension + i;
2561  unsigned int cropSize = m_Parameters.m_Crops[i].first + m_Parameters.m_Crops[i].second;
2562  unsigned int outputSize = inputTensorInfo.GetShape()[spatialDimension] * m_Parameters.m_BlockShape[i];
2563  if (cropSize > outputSize)
2564  {
2565  throw InvalidArgumentException(descriptorName + ": CropSize must be less than or equal to the uncropped"
2566  "outputSize in dimension: " + to_string(spatialDimension) + ".");
2567  }
2568  }
2569 
2570  std::vector<DataType> supportedTypes =
2571  {
2578  };
2579 
2580  ValidateDataTypes(inputTensorInfo, supportedTypes, descriptorName);
2581  ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
2582 }

References armnn::BFloat16, armnn::Float16, armnn::Float32, TensorInfo::GetShape(), BatchToSpaceNdDescriptor::m_BlockShape, BatchToSpaceNdDescriptor::m_Crops, BatchToSpaceNdDescriptor::m_DataLayout, WorkloadInfo::m_InputTensorInfos, WorkloadInfo::m_OutputTensorInfos, QueueDescriptorWithParameters< BatchToSpaceNdDescriptor >::m_Parameters, armnn::NCHW, armnn::QAsymmS8, armnn::QAsymmU8, armnn::QSymmS16, and QueueDescriptor::ValidateTensorNumDimensions().


The documentation for this struct was generated from the following files:
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::BatchToSpaceNdDescriptor::m_BlockShape
std::vector< unsigned int > m_BlockShape
Block shape values.
Definition: Descriptors.hpp:898
armnn::DataType::Float32
@ Float32
armnn::DataType::QAsymmU8
@ QAsymmU8
armnn::BatchToSpaceNdDescriptor::m_Crops
std::vector< std::pair< unsigned int, unsigned int > > m_Crops
The values to crop from the input dimension.
Definition: Descriptors.hpp:900
armnn::DataType::QSymmS16
@ QSymmS16
armnn::DataType::BFloat16
@ BFloat16
armnn::DataType::Float16
@ Float16
armnn::WorkloadInfo::m_OutputTensorInfos
std::vector< TensorInfo > m_OutputTensorInfos
Definition: WorkloadInfo.hpp:19
armnn::QueueDescriptorWithParameters< BatchToSpaceNdDescriptor >::m_Parameters
BatchToSpaceNdDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::InvalidArgumentException
Definition: Exceptions.hpp:80
armnn::DataType::QAsymmS8
@ QAsymmS8
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::BatchToSpaceNdDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:902
armnn::DataLayout::NCHW
@ NCHW