ArmNN
 22.08
ClDepthwiseConvolutionWorkload Class Reference

#include <ClDepthwiseConvolutionWorkload.hpp>

Inheritance diagram for ClDepthwiseConvolutionWorkload:
ClBaseWorkload< DepthwiseConvolution2dQueueDescriptor > BaseWorkload< DepthwiseConvolution2dQueueDescriptor > IWorkload

Public Member Functions

 ClDepthwiseConvolutionWorkload (const DepthwiseConvolution2dQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
 
void Execute () const override
 
- Public Member Functions inherited from ClBaseWorkload< DepthwiseConvolution2dQueueDescriptor >
 ClBaseWorkload (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 ()
 

Protected Attributes

std::unique_ptr< arm_compute::IFunction > m_DepthwiseConvolutionLayer
 
- Protected Attributes inherited from BaseWorkload< DepthwiseConvolution2dQueueDescriptor >
DepthwiseConvolution2dQueueDescriptor m_Data
 
const arm::pipe::ProfilingGuid m_Guid
 

Additional Inherited Members

- Protected Member Functions inherited from ClBaseWorkload< DepthwiseConvolution2dQueueDescriptor >
virtual void Reconfigure ()
 

Detailed Description

Definition at line 24 of file ClDepthwiseConvolutionWorkload.hpp.

Constructor & Destructor Documentation

◆ ClDepthwiseConvolutionWorkload()

ClDepthwiseConvolutionWorkload ( const DepthwiseConvolution2dQueueDescriptor descriptor,
const WorkloadInfo info,
const arm_compute::CLCompileContext &  clCompileContext 
)

Definition at line 88 of file ClDepthwiseConvolutionWorkload.cpp.

References ARMNN_REPORT_PROFILING_WORKLOAD_DESC, BaseWorkload< DepthwiseConvolution2dQueueDescriptor >::GetGuid(), DepthwiseConvolution2dDescriptor::GetNumInputs(), ConstTensorHandle::GetTensorInfo(), DepthwiseConvolution2dQueueDescriptor::m_Bias, DepthwiseConvolution2dDescriptor::m_BiasEnabled, WorkloadInfo::m_BiasTensorInfo, BaseWorkload< DepthwiseConvolution2dQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, WorkloadInfo::m_InputTensorInfos, QueueDescriptor::m_Outputs, WorkloadInfo::m_OutputTensorInfos, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, DepthwiseConvolution2dQueueDescriptor::m_Weight, WorkloadInfo::m_WeightsTensorInfo, and QueueDescriptor::ValidateInputsOutputs().

92  : ClBaseWorkload<DepthwiseConvolution2dQueueDescriptor>(descriptor, info)
93 {
94  // Add details for profiling output
95  WorkloadInfo detailsInfo;
96 
97  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
98  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
99  detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Weight->GetTensorInfo());
100  if (descriptor.m_Parameters.m_BiasEnabled)
101  {
102  detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Bias->GetTensorInfo());
103  }
104 
105  // Report Profiling Details
106  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClDepthwiseConvolutionWorkload_Construct",
107  descriptor.m_Parameters,
108  detailsInfo,
109  GetGuid());
110 
111  m_Data.ValidateInputsOutputs("ClDepthwiseConv2dWorkload", descriptor.m_Parameters.GetNumInputs(), 1);
112 
113  arm_compute::ICLTensor& input = PolymorphicDowncast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
114  arm_compute::ICLTensor& output = PolymorphicDowncast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
115  arm_compute::ICLTensor& weights = PolymorphicDowncast<IClTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
116  arm_compute::ITensorInfo* weightsInfo = weights.info();
117  arm_compute::ITensorInfo* inputInfo = input.info();
118  auto weightsShape = weightsInfo->tensor_shape();
119  auto inputShape = inputInfo->tensor_shape();
120 
121  // The PermuteDepthwiseConv2dWeights backend optimization has been performed,
122  // converting weights to have the same data layout as input.
123  unsigned int depthMultiplier =
124  ComputeDepthwiseConv2dDepthMultiplier(m_Data.m_Parameters.m_DataLayout, weightsShape, inputShape);
125 
126  arm_compute::ICLTensor* bias = nullptr;
128  {
129  bias = &PolymorphicDowncast<IClTensorHandle*>(m_Data.m_Inputs[2])->GetTensor();
130  }
131 
132  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(
135 
136  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
137  input.info()->set_data_layout(aclDataLayout);
138  weights.info()->set_data_layout(aclDataLayout);
139  output.info()->set_data_layout(aclDataLayout);
140 
141  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
142 
143  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
144 
145  m_DepthwiseConvolutionLayer = std::make_unique<arm_compute::CLDepthwiseConvolutionLayer>();
146 
147  {
148  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClDepthwiseConvolutionWorkload_configure");
149  static_cast<arm_compute::CLDepthwiseConvolutionLayer*>(m_DepthwiseConvolutionLayer.get())->configure(
150  clCompileContext,
151  &input,
152  &weights,
153  bias,
154  &output,
155  padStrideInfo,
156  depthMultiplier,
157  activationInfo,
158  aclDilationInfo);
159  }
161 }
bool m_BiasEnabled
Enable/disable bias.
DataLayout
Definition: Types.hpp:62
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::unique_ptr< arm_compute::IFunction > m_DepthwiseConvolutionLayer
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.
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
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< ITensorHandle * > m_Outputs
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
std::vector< ITensorHandle * > m_Inputs

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 163 of file ClDepthwiseConvolutionWorkload.cpp.

References ARMNN_ASSERT, ARMNN_SCOPED_PROFILING_EVENT_CL_GUID, CHECK_LOCATION, BaseWorkload< DepthwiseConvolution2dQueueDescriptor >::GetGuid(), ClDepthwiseConvolutionWorkload::m_DepthwiseConvolutionLayer, and armnn::RunClFunction().

164 {
165  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClDepthwiseConvolutionWorkload_Execute", GetGuid());
167 
169 }
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
std::unique_ptr< arm_compute::IFunction > m_DepthwiseConvolutionLayer
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:61
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203

Member Data Documentation

◆ m_DepthwiseConvolutionLayer

std::unique_ptr<arm_compute::IFunction> m_DepthwiseConvolutionLayer
protected

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