ArmNN
 22.11
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 (ExecutionData &executionData) 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 &)
 
virtual armnn::Optional< armnn::MemoryRequirementsGetMemoryRequirements ()
 

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 89 of file NeonDepthwiseConvolutionWorkload.cpp.

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

93 {
94  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
95  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
96  arm_compute::ITensor& weights = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
97  arm_compute::ITensor* biasesPtr = nullptr;
99  {
100  biasesPtr = &PolymorphicDowncast<IAclTensorHandle *>(m_Data.m_Inputs[2])->GetTensor();
101  }
102 
103  arm_compute::ITensorInfo* weightsInfo = weights.info();
104  arm_compute::ITensorInfo* inputInfo = input.info();
105  auto weightsShape = weightsInfo->tensor_shape();
106  auto inputShape = inputInfo->tensor_shape();
107 
108  // The PermuteDepthwiseConv2dWeights backend optimization has been performed,
109  // converting weights to have the same data layout as input.
110  unsigned int depthMultiplier =
111  ComputeDepthwiseConv2dDepthMultiplier(m_Data.m_Parameters.m_DataLayout, weightsShape, inputShape);
112 
113  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
115 
116  uint32_t numInputs = m_Data.m_Parameters.m_BiasEnabled ? 3: 2;
117  m_Data.ValidateInputsOutputs("NeonDepthwiseConvolutionWorkload", numInputs, 1);
118 
119  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
120  input.info()->set_data_layout(aclDataLayout);
121  weights.info()->set_data_layout(aclDataLayout);
122  output.info()->set_data_layout(aclDataLayout);
123 
124  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
125 
126  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
127 
128  m_pDepthwiseConvolutionLayer = std::make_unique<arm_compute::NEDepthwiseConvolutionLayer>();
129  static_cast<arm_compute::NEDepthwiseConvolutionLayer*>(
130  m_pDepthwiseConvolutionLayer.get())->configure(&input,
131  &weights,
132  biasesPtr,
133  &output,
134  padStrideInfo,
135  depthMultiplier,
136  activationInfo,
137  aclDilationInfo);
138 
139  // Add details for profiling output
140  WorkloadInfo detailsInfo;
141 
142  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
143  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
144  detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Weight->GetTensorInfo());
145  if (descriptor.m_Parameters.m_BiasEnabled)
146  {
147  detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Bias->GetTensorInfo());
148  }
149 
150  // Report Profiling Details
151  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonDepthwiseConvolution2dWorkload_Construct",
152  descriptor.m_Parameters,
153  detailsInfo,
154  GetGuid());
155 
156  ARMNN_ASSERT(m_pDepthwiseConvolutionLayer);
157 
158  m_pDepthwiseConvolutionLayer->prepare();
159 }
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:61
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:83
#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 161 of file NeonDepthwiseConvolutionWorkload.cpp.

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

162 {
163  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonDepthwiseConvolutionWorkload_Execute", GetGuid());
164  ARMNN_ASSERT(m_pDepthwiseConvolutionLayer);
165 
166  m_pDepthwiseConvolutionLayer->run();
167 }
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:61
#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: