ArmNN
 21.02
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 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 >
const 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 77 of file NeonDepthwiseConvolutionWorkload.cpp.

References armnn::ConvertWeightTensorFromArmnnToAcl(), TensorInfo::GetNumBytes(), ConstCpuTensorHandle::GetTensorInfo(), BaseWorkload< DepthwiseConvolution2dQueueDescriptor >::m_Data, DepthwiseConvolution2dDescriptor::m_DataLayout, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and DepthwiseConvolution2dQueueDescriptor::m_Weight.

81 {
82  // ArmNN's weight format is [ M, I, H, W ]
83  auto& weightInfo = m_Data.m_Weight->GetTensorInfo();
84 
85  // Allocate a buffer for the swizzling of the weight tensor
86  std::unique_ptr<unsigned char[]> permuteBuffer(new unsigned char[m_Data.m_Weight->GetTensorInfo().GetNumBytes()]);
87 
88  // Convert the weight format from ArmNN's [ M, I, H, W ] (does NOT depend on the data layout) to either
89  // [ 1, H, W, I * M ] (if NHWC) or [ 1, I * M, H, W ] (if NCHW), as required by the compute library
92  permuteBuffer.get());
93 
94  // Convert the weights into the compute library format
95  m_KernelTensor = std::make_unique<arm_compute::Tensor>();
96  BuildArmComputeTensor(*m_KernelTensor, weightPermuted.GetInfo(), m_Data.m_Parameters.m_DataLayout);
97 
99  {
100  m_BiasTensor = std::make_unique<arm_compute::Tensor>();
101  BuildArmComputeTensor(*m_BiasTensor, m_Data.m_Bias->GetTensorInfo(), m_Data.m_Parameters.m_DataLayout);
102  }
103 
104  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
106 
107  m_Data.ValidateInputsOutputs("NeonDepthwiseConvolutionWorkload", 1, 1);
108 
109  IAclTensorHandle* inputTensorHandle = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0]);
110  IAclTensorHandle* outputTensorHandle = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[0]);
111 
112  arm_compute::ITensor& input = inputTensorHandle->GetTensor();
113  arm_compute::ITensor& output = outputTensorHandle->GetTensor();
114 
115  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
116  input.info()->set_data_layout(aclDataLayout);
117  output.info()->set_data_layout(aclDataLayout);
118 
119  // Get the depth multiplier
120  const unsigned int depthMultiplier = weightInfo.GetShape()[0];
121 
122  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
123 
124  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
125 
126  m_pDepthwiseConvolutionLayer = std::make_unique<arm_compute::NEDepthwiseConvolutionLayer>();
127  static_cast<arm_compute::NEDepthwiseConvolutionLayer*>(
128  m_pDepthwiseConvolutionLayer.get())->configure(&input,
129  m_KernelTensor.get(),
130  m_BiasTensor.get(),
131  &output,
132  padStrideInfo,
133  depthMultiplier,
134  activationInfo,
135  aclDilationInfo);
136 
137  ARMNN_ASSERT(m_pDepthwiseConvolutionLayer);
138 
139  ScopedCpuTensorHandle weightsPermutedHandle(weightPermuted);
140  InitializeArmComputeTensorData(*m_KernelTensor, &weightsPermutedHandle);
141 
143  {
145  }
146 
147  m_pDepthwiseConvolutionLayer->prepare();
148  FreeUnusedTensors();
149 }
virtual arm_compute::ITensor & GetTensor()=0
bool m_BiasEnabled
Enable/disable bias.
DataLayout
Definition: Types.hpp:50
armnn::ConstTensor ConvertWeightTensorFromArmnnToAcl(const ConstCpuTensorHandle *weightTensor, DataLayout dataLayout, void *permuteBuffer)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
const DepthwiseConvolution2dQueueDescriptor m_Data
Definition: Workload.hpp:46
unsigned int GetNumBytes() const
Definition: Tensor.cpp:418
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.
uint32_t m_DilationX
Dilation factor value for width dimension.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, const ConstCpuTensorHandle *handle)
std::vector< ITensorHandle * > m_Outputs
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetTensorInfo() const

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 151 of file NeonDepthwiseConvolutionWorkload.cpp.

References ARMNN_ASSERT, and ARMNN_SCOPED_PROFILING_EVENT_NEON.

152 {
153  ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonDepthwiseConvolutionWorkload_Execute");
154  ARMNN_ASSERT(m_pDepthwiseConvolutionLayer);
155 
156  m_pDepthwiseConvolutionLayer->run();
157 }
#define ARMNN_SCOPED_PROFILING_EVENT_NEON(name)
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14

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