ArmNN
 25.11
Loading...
Searching...
No Matches
SpaceToBatchNdQueueDescriptor Struct Reference

#include <WorkloadData.hpp>

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

Public Member Functions

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

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo & workloadInfo) const

Definition at line 1856 of file WorkloadData.cpp.

1857{
1858 const std::string descriptorName{"SpaceToBatchNdQueueDescriptor"};
1859
1860 ValidateNumInputs(workloadInfo, descriptorName, 1);
1861 ValidateNumOutputs(workloadInfo, descriptorName, 1);
1862
1863 const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
1864 const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
1865
1866 if (m_Parameters.m_BlockShape.size() != m_Parameters.m_PadList.size())
1867 {
1868 throw InvalidArgumentException(descriptorName + ": Pad List must contain the same number of "
1869 "dimensions as Block Shape.");
1870 }
1871
1872 if (m_Parameters.m_BlockShape.size() == 2)
1873 {
1874 ValidateTensorNumDimensions(inputTensorInfo, descriptorName, 4, "input");
1875 ValidateTensorNumDimensions(outputTensorInfo, descriptorName, 4, "output");
1876 }
1877 else if (m_Parameters.m_BlockShape.size() == 1)
1878 {
1879 ValidateTensorNumDimensions(inputTensorInfo, descriptorName, 3, "input");
1880 ValidateTensorNumDimensions(outputTensorInfo, descriptorName, 3, "output");
1881 }
1882 else
1883 {
1884 throw InvalidArgumentException(descriptorName + ": Invalid Block and Crops size.");
1885 }
1886
1887 // Check input + padding and output have the same number of elements
1888 DataLayoutIndexed dimensionIndices(m_Parameters.m_DataLayout);
1889 const unsigned int inputHeight = inputTensorInfo.GetShape()[dimensionIndices.GetHeightIndex()] +
1890 m_Parameters.m_PadList[0].first + m_Parameters.m_PadList[0].second;
1891 const unsigned int inputWidth = (inputTensorInfo.GetNumDimensions() == 3) ? 1 :
1892 inputTensorInfo.GetShape()[dimensionIndices.GetWidthIndex()] +
1893 m_Parameters.m_PadList[1].first + m_Parameters.m_PadList[1].second;
1894
1895 const int channelsIndex_int = (m_Parameters.m_DataLayout == DataLayout::NCHW) ? 1 : -1;
1896 const unsigned int channelsIndex = channelsIndex_int < 0 ?
1897 static_cast<unsigned int>(channelsIndex_int) + inputTensorInfo.GetNumDimensions()
1898 : static_cast<unsigned int>(channelsIndex_int);
1899
1900 const unsigned int numInputElements = inputTensorInfo.GetShape()[0] *
1901 inputHeight *
1902 inputWidth *
1903 inputTensorInfo.GetShape()[channelsIndex];
1904
1905 if (outputTensorInfo.GetNumElements() != numInputElements)
1906 {
1907 throw InvalidArgumentException(descriptorName + ": Input tensor has " +
1908 to_string(numInputElements) + " after padding but output tensor has " +
1909 to_string(outputTensorInfo.GetNumElements()) + " elements.");
1910 }
1911
1912 // In a 4D tensor, there will be 2 spatialDimensions (H and W), and the for loop will run twice.
1913 // In a 3D tensor, there will be 1 spatialDimensions, and the for loop will run once.
1914 unsigned int firstSpatialDimension = m_Parameters.m_DataLayout == DataLayout::NCHW ? 2 : 1;
1915 for (unsigned int i = 0; i < m_Parameters.m_BlockShape.size(); ++i)
1916 {
1917 unsigned int spatialDimension = firstSpatialDimension + i;
1918 auto inputSize = inputTensorInfo.GetShape()[spatialDimension] +
1919 m_Parameters.m_PadList[i].first +
1920 m_Parameters.m_PadList[i].second;
1921 if (inputSize % m_Parameters.m_BlockShape[i] != 0)
1922 {
1923 throw InvalidArgumentException(descriptorName + ": Input dimension size after padding must be "
1924 "divisible by Block Shape in dimension: " + to_string(spatialDimension) + ".");
1925 }
1926 }
1927
1928 std::vector<DataType> supportedTypes =
1929 {
1936 };
1937
1938 ValidateDataTypes(inputTensorInfo, supportedTypes, descriptorName);
1939 ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
1940}
const TensorShape & GetShape() const
Definition Tensor.hpp:193
unsigned int GetNumDimensions() const
Definition Tensor.hpp:197
unsigned int GetNumElements() const
Definition Tensor.hpp:198
void ValidateTensorNumDimensions(const TensorInfo &tensor, std::string const &descName, unsigned int numDimensions, std::string const &tensorName) const
std::vector< unsigned int > m_BlockShape
Block shape value.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left,...
std::vector< TensorInfo > m_OutputTensorInfos
std::vector< TensorInfo > m_InputTensorInfos

References armnn::BFloat16, armnn::Float16, armnn::Float32, DataLayoutIndexed::GetHeightIndex(), TensorInfo::GetNumDimensions(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), DataLayoutIndexed::GetWidthIndex(), WorkloadInfo::m_InputTensorInfos, WorkloadInfo::m_OutputTensorInfos, QueueDescriptorWithParameters< SpaceToBatchNdDescriptor >::m_Parameters, armnn::NCHW, armnn::QAsymmS8, armnn::QAsymmU8, armnn::QSymmS16, and QueueDescriptor::ValidateTensorNumDimensions().


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