ArmNN
 23.05
DepthwiseConvolution2dQueueDescriptor Struct Reference

Depthwise Convolution 2D layer workload data. More...

#include <WorkloadData.hpp>

Inheritance diagram for DepthwiseConvolution2dQueueDescriptor:
QueueDescriptorWithParameters< DepthwiseConvolution2dDescriptor > QueueDescriptor

Public Member Functions

void Validate (const WorkloadInfo &workloadInfo) const
 
- Public Member Functions inherited from QueueDescriptorWithParameters< DepthwiseConvolution2dDescriptor >
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< DepthwiseConvolution2dDescriptor >
DepthwiseConvolution2dDescriptor 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< DepthwiseConvolution2dDescriptor >
 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

Depthwise Convolution 2D layer workload data.

Note
The weights are in the format [1, H, W, I*M]. Where I is the input channel size, M the depthwise mutliplier and H, W is the height and width of the filter kernel. If per channel quantization is applied the weights will be quantized along the last dimension/axis (I*M) which corresponds to the output channel size. If per channel quantization is applied the weights tensor will have I*M scales, one for each dimension of the quantization axis. You have to be aware of this when reshaping the weights tensor. Splitting the I*M axis, e.g. [1, H, W, I*M] --> [H, W, I, M], won't work without taking care of the corresponding quantization scales. If there is no per channel quantization applied reshaping the weights tensor won't cause any issues. There are preconfigured permutation functions available here.

Definition at line 229 of file WorkloadData.hpp.

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 1409 of file WorkloadData.cpp.

1410 {
1411  const std::string descriptorName{"DepthwiseConvolution2dQueueDescriptor"};
1412 
1413  uint32_t numInputs = 2;
1415  {
1416  numInputs = 3;
1417  }
1418 
1419  ValidateNumInputs(workloadInfo, descriptorName, numInputs);
1420  ValidateNumOutputs(workloadInfo, descriptorName, 1);
1421 
1422  const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
1423  const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
1424 
1425  ValidateTensorNumDimensions(inputTensorInfo, descriptorName, 4, "input");
1426  ValidateTensorNumDimensions(outputTensorInfo, descriptorName, 4, "output");
1427 
1428  const TensorInfo& weightTensorInfo = workloadInfo.m_InputTensorInfos[1];
1429  ValidateTensorNumDimensions(weightTensorInfo, descriptorName, 4, "weight");
1430 
1432  {
1434  fmt::format("{}: dilationX (provided {}) and dilationY (provided {}) "
1435  "cannot be smaller than 1.",
1436  descriptorName, m_Parameters.m_DilationX, m_Parameters.m_DilationX));
1437  }
1438 
1439  if (m_Parameters.m_StrideX <= 0 || m_Parameters.m_StrideY <= 0 )
1440  {
1442  fmt::format("{}: strideX (provided {}) and strideY (provided {}) "
1443  "cannot be either negative or 0.",
1444  descriptorName, m_Parameters.m_StrideX, m_Parameters.m_StrideY));
1445  }
1446 
1447  if (weightTensorInfo.GetShape()[0] != 1)
1448  {
1449  throw InvalidArgumentException(fmt::format(
1450  "{0}: The weight format in armnn is expected to be [1, H, W, Cout]."
1451  "But first dimension is not equal to 1. Provided weight shape: [{1}, {2}, {3}, {4}]",
1452  descriptorName,
1453  weightTensorInfo.GetShape()[0],
1454  weightTensorInfo.GetShape()[1],
1455  weightTensorInfo.GetShape()[2],
1456  weightTensorInfo.GetShape()[3]));
1457  }
1458 
1459  const unsigned int channelIndex = (m_Parameters.m_DataLayout == DataLayout::NCHW) ? 1 : 3;
1460  const unsigned int numWeightOutputChannelsRefFormat = weightTensorInfo.GetShape()[3];
1461  const unsigned int numWeightOutputChannelsAclFormat = weightTensorInfo.GetShape()[1];
1462  const unsigned int numOutputChannels = outputTensorInfo.GetShape()[channelIndex];
1463 
1464  // Weights format has two valid options: [1, H, W, Cout] (CpuRef) or [1, Cout, H, W] (CpuAcc/GpuAcc).
1465  bool validRefFormat = (numWeightOutputChannelsRefFormat == numOutputChannels);
1466  bool validAclFormat = (numWeightOutputChannelsAclFormat == numOutputChannels);
1467 
1468  if (!(validRefFormat || validAclFormat))
1469  {
1470  throw InvalidArgumentException(fmt::format(
1471  "{0}: The weight format in armnn is expected to be [1, H, W, Cout] (CpuRef) or [1, Cout, H, W] "
1472  "(CpuAcc/GpuAcc). But neither the 4th (CpuRef) or 2nd (CpuAcc/GpuAcc) dimension is equal to Cout."
1473  "Cout = {1} Provided weight shape: [{2}, {3}, {4}, {5}]",
1474  descriptorName,
1475  numOutputChannels,
1476  weightTensorInfo.GetShape()[0],
1477  weightTensorInfo.GetShape()[1],
1478  weightTensorInfo.GetShape()[2],
1479  weightTensorInfo.GetShape()[3]));
1480  }
1481 
1482  ValidateWeightDataType(inputTensorInfo, weightTensorInfo, descriptorName);
1483 
1484  Optional<TensorInfo> optionalBiasTensorInfo;
1486  {
1487  optionalBiasTensorInfo = MakeOptional<TensorInfo>(workloadInfo.m_InputTensorInfos[2]);
1488  const TensorInfo& biasTensorInfo = optionalBiasTensorInfo.value();
1489 
1490  ValidateBiasTensorQuantization(biasTensorInfo, inputTensorInfo, weightTensorInfo, descriptorName);
1491  ValidateTensorDataType(biasTensorInfo, GetBiasDataType(inputTensorInfo.GetDataType()), descriptorName, "bias");
1492  }
1493  ValidatePerAxisQuantization(inputTensorInfo,
1494  outputTensorInfo,
1495  weightTensorInfo,
1496  optionalBiasTensorInfo,
1497  descriptorName);
1498 
1499  std::vector<DataType> supportedTypes =
1500  {
1507  };
1508 
1509  ValidateDataTypes(inputTensorInfo, supportedTypes, descriptorName);
1510  ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
1511 }

References armnn::BFloat16, armnn::Float16, armnn::Float32, armnn::GetBiasDataType(), TensorInfo::GetDataType(), TensorInfo::GetShape(), DepthwiseConvolution2dDescriptor::m_BiasEnabled, DepthwiseConvolution2dDescriptor::m_DataLayout, DepthwiseConvolution2dDescriptor::m_DilationX, DepthwiseConvolution2dDescriptor::m_DilationY, WorkloadInfo::m_InputTensorInfos, WorkloadInfo::m_OutputTensorInfos, QueueDescriptorWithParameters< DepthwiseConvolution2dDescriptor >::m_Parameters, DepthwiseConvolution2dDescriptor::m_StrideX, DepthwiseConvolution2dDescriptor::m_StrideY, armnn::NCHW, armnn::QAsymmS8, armnn::QAsymmU8, armnn::QSymmS16, QueueDescriptor::ValidateTensorNumDimensions(), and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().


The documentation for this struct was generated from the following files:
armnn::DataType::QAsymmU8
@ QAsymmU8
armnn::DataType::Float16
@ Float16
armnn::DepthwiseConvolution2dDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:696
armnn::GetBiasDataType
DataType GetBiasDataType(DataType inputDataType)
Definition: WorkloadData.cpp:28
armnn::DataType::QAsymmS8
@ QAsymmS8
armnn::DepthwiseConvolution2dDescriptor::m_StrideX
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
Definition: Descriptors.hpp:688
armnn::DepthwiseConvolution2dDescriptor::m_DilationX
uint32_t m_DilationX
Dilation factor value for width dimension.
Definition: Descriptors.hpp:692
armnn::OptionalReferenceSwitch< std::is_reference< T >::value, T >::value
const T & value() const
Definition: Optional.hpp:146
armnn::DepthwiseConvolution2dDescriptor::m_DilationY
uint32_t m_DilationY
Dilation factor value for height dimension.
Definition: Descriptors.hpp:694
armnn::DataLayout::NCHW
@ NCHW
armnn::WorkloadInfo::m_OutputTensorInfos
std::vector< TensorInfo > m_OutputTensorInfos
Definition: WorkloadInfo.hpp:19
armnn::DepthwiseConvolution2dDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:698
armnn::QueueDescriptor::ValidateTensorNumDimensions
void ValidateTensorNumDimensions(const TensorInfo &tensor, std::string const &descName, unsigned int numDimensions, std::string const &tensorName) const
Definition: WorkloadData.cpp:423
armnn::DataType::Float32
@ Float32
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
armnn::QueueDescriptorWithParameters< DepthwiseConvolution2dDescriptor >::m_Parameters
DepthwiseConvolution2dDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::DataType::BFloat16
@ BFloat16
armnn::Optional
Definition: Optional.hpp:270
armnn::DataType::QSymmS16
@ QSymmS16
armnn::DepthwiseConvolution2dDescriptor::m_StrideY
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
Definition: Descriptors.hpp:690
armnn::InvalidArgumentException
Definition: Exceptions.hpp:80
armnn::TensorInfo::GetDataType
DataType GetDataType() const
Definition: Tensor.hpp:198
armnn::WorkloadInfo::m_InputTensorInfos
std::vector< TensorInfo > m_InputTensorInfos
Definition: WorkloadInfo.hpp:18