ArmNN
 21.08
DepthwiseConvolution2dQueueDescriptor Struct Reference

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

#include <WorkloadData.hpp>

Inheritance diagram for DepthwiseConvolution2dQueueDescriptor:
QueueDescriptorWithParameters< DepthwiseConvolution2dDescriptor > QueueDescriptor

Public Member Functions

 DepthwiseConvolution2dQueueDescriptor ()
 
void Validate (const WorkloadInfo &workloadInfo) const
 
- Public Member Functions inherited from QueueDescriptor
void ValidateInputsOutputs (const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
 
template<typename T >
const T * GetAdditionalInformation () const
 

Public Attributes

const ConstTensorHandlem_Weight
 
const ConstTensorHandlem_Bias
 
- 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
 

Additional Inherited Members

- Protected Member Functions inherited from QueueDescriptorWithParameters< DepthwiseConvolution2dDescriptor >
 ~QueueDescriptorWithParameters ()=default
 
 QueueDescriptorWithParameters ()=default
 
 QueueDescriptorWithParameters (QueueDescriptorWithParameters const &)=default
 
QueueDescriptorWithParametersoperator= (QueueDescriptorWithParameters const &)=default
 
- Protected Member Functions inherited from QueueDescriptor
 ~QueueDescriptor ()=default
 
 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 224 of file WorkloadData.hpp.

Constructor & Destructor Documentation

◆ DepthwiseConvolution2dQueueDescriptor()

Definition at line 226 of file WorkloadData.hpp.

227  : m_Weight(nullptr)
228  , m_Bias(nullptr)
229  {
230  }

Member Function Documentation

◆ Validate()

void Validate ( const WorkloadInfo workloadInfo) const

Definition at line 1325 of file WorkloadData.cpp.

References armnn::BFloat16, armnn::Float16, armnn::Float32, armnn::GetBiasDataType(), TensorInfo::GetDataType(), TensorInfo::GetShape(), WorkloadInfo::m_InputTensorInfos, WorkloadInfo::m_OutputTensorInfos, armnn::NCHW, armnn::QAsymmS8, armnn::QAsymmU8, armnn::QSymmS16, and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

1326 {
1327  const std::string descriptorName{"DepthwiseConvolution2dQueueDescriptor"};
1328 
1329  ValidateNumInputs(workloadInfo, descriptorName, 1);
1330  ValidateNumOutputs(workloadInfo, descriptorName, 1);
1331 
1332  const TensorInfo& inputTensorInfo = workloadInfo.m_InputTensorInfos[0];
1333  const TensorInfo& outputTensorInfo = workloadInfo.m_OutputTensorInfos[0];
1334 
1335  ValidateTensorNumDimensions(inputTensorInfo, descriptorName, 4, "input");
1336  ValidateTensorNumDimensions(outputTensorInfo, descriptorName, 4, "output");
1337 
1338  ValidatePointer(m_Weight, descriptorName, "weight");
1339 
1340  const TensorInfo& weightTensorInfo = m_Weight->GetTensorInfo();
1341  ValidateTensorNumDimensions(weightTensorInfo, descriptorName, 4, "weight");
1342 
1344  {
1346  fmt::format("{}: dilationX (provided {}) and dilationY (provided {}) "
1347  "cannot be smaller than 1.",
1348  descriptorName, m_Parameters.m_DilationX, m_Parameters.m_DilationX));
1349  }
1350 
1351  if (m_Parameters.m_StrideX <= 0 || m_Parameters.m_StrideY <= 0 )
1352  {
1354  fmt::format("{}: strideX (provided {}) and strideY (provided {}) "
1355  "cannot be either negative or 0.",
1356  descriptorName, m_Parameters.m_StrideX, m_Parameters.m_StrideY));
1357  }
1358 
1359  const unsigned int channelIndex = (m_Parameters.m_DataLayout == DataLayout::NCHW) ? 1 : 3;
1360 
1361  // Expected weight shape: [ 1, H, W, I*M ] - This shape does NOT depend on the data layout
1362  // inputChannels * channelMultiplier should be equal to outputChannels.
1363  const unsigned int numWeightOutputChannels = weightTensorInfo.GetShape()[3]; // I*M=Cout
1364  const unsigned int numOutputChannels = outputTensorInfo.GetShape()[channelIndex];
1365  if (numWeightOutputChannels != numOutputChannels)
1366  {
1367  throw InvalidArgumentException(fmt::format(
1368  "{0}: The weight format in armnn is expected to be [1, H, W, Cout]."
1369  "But 4th dimension is not equal to Cout. Cout = {1} Provided weight shape: [{2}, {3}, {4}, {5}]",
1370  descriptorName,
1371  numOutputChannels,
1372  weightTensorInfo.GetShape()[0],
1373  weightTensorInfo.GetShape()[1],
1374  weightTensorInfo.GetShape()[2],
1375  weightTensorInfo.GetShape()[3]));
1376  }
1377  if (weightTensorInfo.GetShape()[0] != 1)
1378  {
1379  throw InvalidArgumentException(fmt::format(
1380  "{0}: The weight format in armnn is expected to be [1, H, W, Cout]."
1381  "But first dimension is not equal to 1. Provided weight shape: [{1}, {2}, {3}, {4}]",
1382  descriptorName,
1383  weightTensorInfo.GetShape()[0],
1384  weightTensorInfo.GetShape()[1],
1385  weightTensorInfo.GetShape()[2],
1386  weightTensorInfo.GetShape()[3]));
1387  }
1388 
1389  ValidateWeightDataType(inputTensorInfo, weightTensorInfo, descriptorName);
1390 
1391  Optional<TensorInfo> optionalBiasTensorInfo;
1393  {
1394  ValidatePointer(m_Bias, descriptorName, "bias");
1395 
1396  optionalBiasTensorInfo = MakeOptional<TensorInfo>(m_Bias->GetTensorInfo());
1397  const TensorInfo& biasTensorInfo = optionalBiasTensorInfo.value();
1398 
1399  ValidateBiasTensorQuantization(biasTensorInfo, inputTensorInfo, weightTensorInfo, descriptorName);
1400  ValidateTensorDataType(biasTensorInfo, GetBiasDataType(inputTensorInfo.GetDataType()), descriptorName, "bias");
1401  }
1402  ValidatePerAxisQuantization(inputTensorInfo,
1403  outputTensorInfo,
1404  weightTensorInfo,
1405  optionalBiasTensorInfo,
1406  descriptorName);
1407 
1408  std::vector<DataType> supportedTypes =
1409  {
1416  };
1417 
1418  ValidateDataTypes(inputTensorInfo, supportedTypes, descriptorName);
1419  ValidateTensorDataTypesMatch(inputTensorInfo, outputTensorInfo, descriptorName, "input", "output");
1420 }
bool m_BiasEnabled
Enable/disable bias.
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
uint32_t m_DilationY
Dilation factor value for height dimension.
const TensorInfo & GetTensorInfo() const
std::vector< TensorInfo > m_InputTensorInfos
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_DilationX
Dilation factor value for width dimension.
DataType GetDataType() const
Definition: Tensor.hpp:198
std::vector< TensorInfo > m_OutputTensorInfos
DataType GetBiasDataType(DataType inputDataType)
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.

Member Data Documentation

◆ m_Bias

◆ m_Weight


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