ArmNN
 24.08
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 2528 of file WorkloadData.cpp.

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

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:398
armnn::BatchToSpaceNdDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:902
armnn::DataLayout::NCHW
@ NCHW