ArmNN
 20.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 24 of file NeonDepthwiseConvolutionWorkload.hpp.

Constructor & Destructor Documentation

◆ NeonDepthwiseConvolutionWorkload()

Definition at line 72 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.

76 {
77  // ArmNN's weight format is [ M, I, H, W ]
78  auto& weightInfo = m_Data.m_Weight->GetTensorInfo();
79 
80  // Allocate a buffer for the swizzling of the weight tensor
81  std::unique_ptr<unsigned char[]> permuteBuffer(new unsigned char[m_Data.m_Weight->GetTensorInfo().GetNumBytes()]);
82 
83  // Convert the weight format from ArmNN's [ M, I, H, W ] (does NOT depend on the data layout) to either
84  // [ 1, H, W, I * M ] (if NHWC) or [ 1, I * M, H, W ] (if NCHW), as required by the compute library
87  permuteBuffer.get());
88 
89  // Convert the weights into the compute library format
90  m_KernelTensor = std::make_unique<arm_compute::Tensor>();
91  BuildArmComputeTensor(*m_KernelTensor, weightPermuted.GetInfo(), m_Data.m_Parameters.m_DataLayout);
92 
94  {
95  m_BiasTensor = std::make_unique<arm_compute::Tensor>();
96  BuildArmComputeTensor(*m_BiasTensor, m_Data.m_Bias->GetTensorInfo(), m_Data.m_Parameters.m_DataLayout);
97  }
98 
99  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
101 
102  m_Data.ValidateInputsOutputs("NeonDepthwiseConvolutionWorkload", 1, 1);
103 
104  IAclTensorHandle* inputTensorHandle = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0]);
105  IAclTensorHandle* outputTensorHandle = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[0]);
106 
107  arm_compute::ITensor& input = inputTensorHandle->GetTensor();
108  arm_compute::ITensor& output = outputTensorHandle->GetTensor();
109 
110  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
111  input.info()->set_data_layout(aclDataLayout);
112  output.info()->set_data_layout(aclDataLayout);
113 
114  // Get the depth multiplier
115  const unsigned int depthMultiplier = weightInfo.GetShape()[0];
116 
117  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
118 
119  m_pDepthwiseConvolutionLayer = std::make_unique<arm_compute::NEDepthwiseConvolutionLayer>();
120  static_cast<arm_compute::NEDepthwiseConvolutionLayer*>(
121  m_pDepthwiseConvolutionLayer.get())->configure(&input,
122  m_KernelTensor.get(),
123  m_BiasTensor.get(),
124  &output,
125  padStrideInfo,
126  depthMultiplier,
127  arm_compute::ActivationLayerInfo(),
128  aclDilationInfo);
129 
130  BOOST_ASSERT(m_pDepthwiseConvolutionLayer);
131 
132  ScopedCpuTensorHandle weightsPermutedHandle(weightPermuted);
133  InitializeArmComputeTensorData(*m_KernelTensor, &weightsPermutedHandle);
134 
136  {
138  }
139 
140  m_pDepthwiseConvolutionLayer->prepare();
141  FreeUnusedTensors();
142 }
virtual arm_compute::ITensor & GetTensor()=0
bool m_BiasEnabled
Enable/disable bias.
DataLayout
Definition: Types.hpp:49
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:213
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:199
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 144 of file NeonDepthwiseConvolutionWorkload.cpp.

References ARMNN_SCOPED_PROFILING_EVENT_NEON.

145 {
146  ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonDepthwiseConvolutionWorkload_Execute");
147  BOOST_ASSERT(m_pDepthwiseConvolutionLayer);
148 
149  m_pDepthwiseConvolutionLayer->run();
150 }
#define ARMNN_SCOPED_PROFILING_EVENT_NEON(name)

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