ArmNN
 21.11
NeonDepthwiseConvolutionWorkload Class Reference

#include <NeonDepthwiseConvolutionWorkload.hpp>

Inheritance diagram for NeonDepthwiseConvolutionWorkload:
BaseWorkload< DepthwiseConvolution2dQueueDescriptor > IWorkload

Public Member Functions

 NeonDepthwiseConvolutionWorkload (const DepthwiseConvolution2dQueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual void Execute () const 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
 
profiling::ProfilingGuid GetGuid () const final
 
- Public Member Functions inherited from IWorkload
virtual ~IWorkload ()
 
virtual void RegisterDebugCallback (const DebugCallbackFunction &)
 

Additional Inherited Members

- Protected Attributes inherited from BaseWorkload< DepthwiseConvolution2dQueueDescriptor >
DepthwiseConvolution2dQueueDescriptor m_Data
 
const profiling::ProfilingGuid m_Guid
 

Detailed Description

Definition at line 26 of file NeonDepthwiseConvolutionWorkload.hpp.

Constructor & Destructor Documentation

◆ NeonDepthwiseConvolutionWorkload()

Definition at line 76 of file NeonDepthwiseConvolutionWorkload.cpp.

References armnn::Convert1HWOTensorToAcl(), ConstTensorHandle::GetTensorInfo(), BaseWorkload< DepthwiseConvolution2dQueueDescriptor >::m_Data, DepthwiseConvolution2dDescriptor::m_DataLayout, WorkloadInfo::m_InputTensorInfos, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and DepthwiseConvolution2dQueueDescriptor::m_Weight.

80 {
81  // ArmNN's weight format for depthwise is [ 1, H, W, I*M ]
82  auto& weightInfo = m_Data.m_Weight->GetTensorInfo();
83 
84  ConstTensor weightsPermuted;
85  unsigned int depthMultiplier;
86  std::unique_ptr<unsigned char[]> permuteBuffer(new unsigned char[weightInfo.GetNumBytes()]);
87  std::tie(weightsPermuted, depthMultiplier) = Convert1HWOTensorToAcl(m_Data.m_Weight,
88  info.m_InputTensorInfos[0],
90  permuteBuffer.get());
91 
92  // Convert the weights into the compute library format
93  m_KernelTensor = std::make_unique<arm_compute::Tensor>();
94  BuildArmComputeTensor(*m_KernelTensor, weightsPermuted.GetInfo(), m_Data.m_Parameters.m_DataLayout);
95 
97  {
98  m_BiasTensor = std::make_unique<arm_compute::Tensor>();
99  BuildArmComputeTensor(*m_BiasTensor, m_Data.m_Bias->GetTensorInfo(), m_Data.m_Parameters.m_DataLayout);
100  }
101 
102  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
104 
105  m_Data.ValidateInputsOutputs("NeonDepthwiseConvolutionWorkload", 1, 1);
106 
107  IAclTensorHandle* inputTensorHandle = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0]);
108  IAclTensorHandle* outputTensorHandle = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[0]);
109 
110  arm_compute::ITensor& input = inputTensorHandle->GetTensor();
111  arm_compute::ITensor& output = outputTensorHandle->GetTensor();
112 
113  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
114  input.info()->set_data_layout(aclDataLayout);
115  output.info()->set_data_layout(aclDataLayout);
116 
117  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
118 
119  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
120 
121  m_pDepthwiseConvolutionLayer = std::make_unique<arm_compute::NEDepthwiseConvolutionLayer>();
122  static_cast<arm_compute::NEDepthwiseConvolutionLayer*>(
123  m_pDepthwiseConvolutionLayer.get())->configure(&input,
124  m_KernelTensor.get(),
125  m_BiasTensor.get(),
126  &output,
127  padStrideInfo,
128  depthMultiplier,
129  activationInfo,
130  aclDilationInfo);
131 
132  // Add details for profiling output
133  WorkloadInfo detailsInfo;
134 
135  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
136  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
137  detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Weight->GetTensorInfo());
138  if (descriptor.m_Parameters.m_BiasEnabled)
139  {
140  detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Bias->GetTensorInfo());
141  }
142 
143  // Report Profiling Details
144  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonDepthwiseConvolution2dWorkload_Construct",
145  descriptor.m_Parameters,
146  detailsInfo,
147  this->GetGuid());
148 
149  ARMNN_ASSERT(m_pDepthwiseConvolutionLayer);
150 
151  ScopedTensorHandle weightsPermutedHandle(weightsPermuted);
152  InitializeArmComputeTensorData(*m_KernelTensor, &weightsPermutedHandle);
153 
155  {
157  }
158 
159  m_pDepthwiseConvolutionLayer->prepare();
160  FreeUnusedTensors();
161 }
virtual arm_compute::ITensor & GetTensor()=0
bool m_BiasEnabled
Enable/disable bias.
DataLayout
Definition: Types.hpp:49
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
uint32_t m_DilationY
Dilation factor value for height dimension.
const TensorInfo & GetTensorInfo() const
std::vector< TensorInfo > m_InputTensorInfos
std::tuple< ConstTensor, unsigned int > Convert1HWOTensorToAcl(const ConstTensorHandle *weightTensor, const TensorInfo &inputInfo, const DataLayout dataLayout, void *permuteBuffer)
Weights for depthwise have a datalayout of [1,H,W,O] = [1,H,W,I*M] This function coverts a ConstCpuTe...
uint32_t m_DilationX
Dilation factor value for width dimension.
DepthwiseConvolution2dQueueDescriptor m_Data
Definition: Workload.hpp:58
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:327
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
std::vector< TensorInfo > m_OutputTensorInfos
const TensorInfo & GetInfo() const
Definition: Tensor.hpp:295
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
std::vector< ITensorHandle * > m_Outputs
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, const ConstTensorHandle *handle)
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 163 of file NeonDepthwiseConvolutionWorkload.cpp.

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

164 {
165  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonDepthwiseConvolutionWorkload_Execute", this->GetGuid());
166  ARMNN_ASSERT(m_pDepthwiseConvolutionLayer);
167 
168  m_pDepthwiseConvolutionLayer->run();
169 }
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)

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