ArmNN
 22.05.01
NeonDepthwiseConvolutionWorkload Class Reference

#include <NeonDepthwiseConvolutionWorkload.hpp>

Inheritance diagram for NeonDepthwiseConvolutionWorkload:
NeonBaseWorkload< DepthwiseConvolution2dQueueDescriptor > BaseWorkload< DepthwiseConvolution2dQueueDescriptor > IWorkload

Public Member Functions

 NeonDepthwiseConvolutionWorkload (const DepthwiseConvolution2dQueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual void Execute () const override
 
- Public Member Functions inherited from NeonBaseWorkload< DepthwiseConvolution2dQueueDescriptor >
 NeonBaseWorkload (const DepthwiseConvolution2dQueueDescriptor &descriptor, const WorkloadInfo &info)
 
void ReplaceInputTensorHandle (ITensorHandle *tensorHandle, unsigned int slot) override
 
void ReplaceOutputTensorHandle (ITensorHandle *tensorHandle, unsigned int slot) override
 
- Public Member Functions inherited from BaseWorkload< DepthwiseConvolution2dQueueDescriptor >
 BaseWorkload (const DepthwiseConvolution2dQueueDescriptor &descriptor, const WorkloadInfo &info)
 
void ExecuteAsync (WorkingMemDescriptor &workingMemDescriptor) override
 
void PostAllocationConfigure () override
 
const DepthwiseConvolution2dQueueDescriptorGetData () const
 
arm::pipe::ProfilingGuid GetGuid () const final
 
virtual bool SupportsTensorHandleReplacement () const override
 
- Public Member Functions inherited from IWorkload
virtual ~IWorkload ()
 
virtual void RegisterDebugCallback (const DebugCallbackFunction &)
 

Additional Inherited Members

- Protected Member Functions inherited from NeonBaseWorkload< DepthwiseConvolution2dQueueDescriptor >
virtual void Reconfigure ()
 
- Protected Attributes inherited from BaseWorkload< DepthwiseConvolution2dQueueDescriptor >
DepthwiseConvolution2dQueueDescriptor m_Data
 
const arm::pipe::ProfilingGuid m_Guid
 

Detailed Description

Definition at line 26 of file NeonDepthwiseConvolutionWorkload.hpp.

Constructor & Destructor Documentation

◆ NeonDepthwiseConvolutionWorkload()

Definition at line 98 of file NeonDepthwiseConvolutionWorkload.cpp.

References DepthwiseConvolution2dDescriptor::m_BiasEnabled, BaseWorkload< DepthwiseConvolution2dQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, QueueDescriptor::m_Outputs, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

102 {
103  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
104  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
105  arm_compute::ITensor& weights = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
106  arm_compute::ITensor* biasesPtr = nullptr;
108  {
109  biasesPtr = &PolymorphicDowncast<IAclTensorHandle *>(m_Data.m_Inputs[2])->GetTensor();
110  }
111 
112  arm_compute::ITensorInfo* weightsInfo = weights.info();
113  arm_compute::ITensorInfo* inputInfo = input.info();
114  auto weightsShape = weightsInfo->tensor_shape();
115  auto inputShape = inputInfo->tensor_shape();
116 
117  // The PermuteDepthwiseConv2dWeights backend optimization has been performed,
118  // converting weights to have the same data layout as input.
119  unsigned int depthMultiplier =
120  ComputeDepthwiseConv2dDepthMultiplier(m_Data.m_Parameters.m_DataLayout, weightsShape, inputShape);
121 
122  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
124 
125  uint32_t numInputs = m_Data.m_Parameters.m_BiasEnabled ? 3: 2;
126  m_Data.ValidateInputsOutputs("NeonDepthwiseConvolutionWorkload", numInputs, 1);
127 
128  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
129  input.info()->set_data_layout(aclDataLayout);
130  weights.info()->set_data_layout(aclDataLayout);
131  output.info()->set_data_layout(aclDataLayout);
132 
133  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
134 
135  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
136 
137  m_pDepthwiseConvolutionLayer = std::make_unique<arm_compute::NEDepthwiseConvolutionLayer>();
138  static_cast<arm_compute::NEDepthwiseConvolutionLayer*>(
139  m_pDepthwiseConvolutionLayer.get())->configure(&input,
140  &weights,
141  biasesPtr,
142  &output,
143  padStrideInfo,
144  depthMultiplier,
145  activationInfo,
146  aclDilationInfo);
147 
148  // Add details for profiling output
149  WorkloadInfo detailsInfo;
150 
151  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
152  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
153  detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Weight->GetTensorInfo());
154  if (descriptor.m_Parameters.m_BiasEnabled)
155  {
156  detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Bias->GetTensorInfo());
157  }
158 
159  // Report Profiling Details
160  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonDepthwiseConvolution2dWorkload_Construct",
161  descriptor.m_Parameters,
162  detailsInfo,
163  GetGuid());
164 
165  ARMNN_ASSERT(m_pDepthwiseConvolutionLayer);
166 
167  m_pDepthwiseConvolutionLayer->prepare();
168 }
bool m_BiasEnabled
Enable/disable bias.
DataLayout
Definition: Types.hpp:62
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:59
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
uint32_t m_DilationY
Dilation factor value for height dimension.
std::vector< TensorInfo > m_InputTensorInfos
uint32_t m_DilationX
Dilation factor value for width dimension.
DepthwiseConvolution2dQueueDescriptor m_Data
Definition: Workload.hpp:81
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::vector< TensorInfo > m_OutputTensorInfos
Optional< TensorInfo > m_BiasTensorInfo
std::vector< ITensorHandle * > m_Outputs
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
Optional< TensorInfo > m_WeightsTensorInfo

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 170 of file NeonDepthwiseConvolutionWorkload.cpp.

References ARMNN_ASSERT, ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID, and BaseWorkload< DepthwiseConvolution2dQueueDescriptor >::GetGuid().

171 {
172  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonDepthwiseConvolutionWorkload_Execute", GetGuid());
173  ARMNN_ASSERT(m_pDepthwiseConvolutionLayer);
174 
175  m_pDepthwiseConvolutionLayer->run();
176 }
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:59
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)

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