ArmNN
 24.02
ClConvolution2dWorkload Class Reference

#include <ClConvolution2dWorkload.hpp>

Inheritance diagram for ClConvolution2dWorkload:
[legend]
Collaboration diagram for ClConvolution2dWorkload:
[legend]

Public Member Functions

 ClConvolution2dWorkload (const Convolution2dQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager, const arm_compute::CLCompileContext &clCompileContext, const bool isFastMathEnabled=false)
 
void Execute () const override
 
arm_compute::ConvolutionMethod GetConvolutionMethod () const
 
bool SupportsTensorHandleReplacement () const override
 
- Public Member Functions inherited from ClBaseWorkload< Convolution2dQueueDescriptor >
 ClBaseWorkload (const Convolution2dQueueDescriptor &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< Convolution2dQueueDescriptor >
 BaseWorkload (const Convolution2dQueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual const std::string & GetName () const override
 
void ExecuteAsync (ExecutionData &executionData) override
 
void PostAllocationConfigure () override
 
const Convolution2dQueueDescriptorGetData () const
 
arm::pipe::ProfilingGuid GetGuid () const final
 
virtual bool SupportsTensorHandleReplacement () const override
 
- Public Member Functions inherited from IWorkload
virtual ~IWorkload ()
 
virtual arm::pipe::ProfilingGuid GetGuid () const =0
 
virtual const std::string & GetName () const =0
 
virtual void RegisterDebugCallback (const DebugCallbackFunction &)
 
virtual armnn::Optional< armnn::MemoryRequirementsGetMemoryRequirements ()
 

Protected Member Functions

void Reconfigure () override
 

Additional Inherited Members

- Protected Attributes inherited from BaseWorkload< Convolution2dQueueDescriptor >
Convolution2dQueueDescriptor m_Data
 
const arm::pipe::ProfilingGuid m_Guid
 
const std::string m_Name
 

Detailed Description

Definition at line 31 of file ClConvolution2dWorkload.hpp.

Constructor & Destructor Documentation

◆ ClConvolution2dWorkload()

ClConvolution2dWorkload ( const Convolution2dQueueDescriptor descriptor,
const WorkloadInfo info,
std::shared_ptr< arm_compute::MemoryManagerOnDemand > &  memoryManager,
const arm_compute::CLCompileContext &  clCompileContext,
const bool  isFastMathEnabled = false 
)

Definition at line 76 of file ClConvolution2dWorkload.cpp.

81  : ClBaseWorkload<Convolution2dQueueDescriptor>(descriptor, info)
82  , m_ConvolutionLayer(memoryManager)
83 {
84  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClConvolution2dWorkload");
85 
86  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(m_Data.m_Parameters.m_DilationX,
88 
89  uint32_t numInputs = m_Data.m_Parameters.m_BiasEnabled ? 3: 2;
90  m_Data.ValidateInputsOutputs("ClConvolution2dWorkload", numInputs, 1);
91 
92  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
93  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
94  arm_compute::ICLTensor& weights = static_cast<IClTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
95  weights.info()->set_are_values_constant(info.m_InputTensorInfos[1].IsConstant());
96 
98  {
99  arm_compute::ICLTensor& bias = static_cast<IClTensorHandle*>(m_Data.m_Inputs[2])->GetTensor();
100  bias.info()->set_are_values_constant(info.m_InputTensorInfos[2].IsConstant());
101  // We assume here that NeonConvolution2dWorkloadValidate has been called before the constructor.
102  ARMNN_ASSERT(info.m_InputTensorInfos[2].IsConstant() == true);
103  m_BiasProxy = std::make_unique<ICLTensorProxy>(&bias);
104  }
105 
106  // Create Proxy tensor and set the initial tensor handle to it
107  m_InputProxy = std::make_unique<ICLTensorProxy>(&input);
108  m_OutputProxy = std::make_unique<ICLTensorProxy>(&output);
109  m_WeightsProxy = std::make_unique<ICLTensorProxy>(&weights);
110 
111  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
112  input.info()->set_data_layout(aclDataLayout);
113  output.info()->set_data_layout(aclDataLayout);
114  weights.info()->set_data_layout(aclDataLayout);
115 
116  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
117 
118  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
119 
120  {
121  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClConvolution2dWorkload_configure");
122  m_ConvolutionLayer.configure(clCompileContext,
123  m_InputProxy.get(),
124  m_WeightsProxy.get(),
125  m_BiasProxy.get(),
126  m_OutputProxy.get(),
127  padStrideInfo,
128  arm_compute::WeightsInfo(),
129  aclDilationInfo,
130  activationInfo,
131  isFastMathEnabled);
132  }
133 
134  m_ConvolutionMethod =
135  m_ConvolutionLayer.get_convolution_method(input.info(),
136  weights.info(),
137  output.info(),
138  padStrideInfo,
139  arm_compute::WeightsInfo(),
140  activationInfo,
141  arm_compute::CLScheduler::get().target(),
142  aclDilationInfo,
143  isFastMathEnabled);
144 
145  // Add details for profiling output
146  WorkloadInfo detailsInfo;
147 
148  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
149  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
150  detailsInfo.m_ConvolutionMethod = armnn::Optional<std::string>(GetConvolutionMethodString(m_ConvolutionMethod));
151 
152  // Report Profiling Details
153  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClConvolution2dWorkload_Construct",
154  descriptor.m_Parameters,
155  detailsInfo,
156  GetGuid());
157 }

References ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID, and armnn::info.

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 159 of file ClConvolution2dWorkload.cpp.

160 {
161  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClConvolution2dWorkload_Execute");
162  RunClFunction(m_ConvolutionLayer, CHECK_LOCATION());
163 }

References ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID, CHECK_LOCATION, and armnn::RunClFunction().

◆ GetConvolutionMethod()

arm_compute::ConvolutionMethod GetConvolutionMethod ( ) const

Definition at line 165 of file ClConvolution2dWorkload.cpp.

166 {
167  return m_ConvolutionMethod;
168 }

◆ Reconfigure()

void Reconfigure ( )
overrideprotectedvirtual

Reimplemented from ClBaseWorkload< Convolution2dQueueDescriptor >.

Definition at line 170 of file ClConvolution2dWorkload.cpp.

171 {
172  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
173  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
174 
175  m_InputProxy->set(&input);
176  m_OutputProxy->set(&output);
177 }

References BaseWorkload< Convolution2dQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, and QueueDescriptor::m_Outputs.

◆ SupportsTensorHandleReplacement()

bool SupportsTensorHandleReplacement ( ) const
inlineoverridevirtual

Implements IWorkload.

Definition at line 43 of file ClConvolution2dWorkload.hpp.

44  {
45  // NCHW DataLayout on ACL still uses paddding for alignment on the Conv2d workload so importing is unreliable.
47  {
48  return false;
49  }
50  else
51  {
52  return true;
53  }
54  }

References BaseWorkload< Convolution2dQueueDescriptor >::m_Data, Convolution2dDescriptor::m_DataLayout, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and armnn::NCHW.


The documentation for this class was generated from the following files:
ARMNN_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::Optional< std::string >
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:446
armnn::ConvertAdditionalInfoToAclActivationLayerInfo
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
Definition: ArmComputeUtils.hpp:105
CHECK_LOCATION
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
armnn::Convolution2dDescriptor::m_DilationY
uint32_t m_DilationY
Dilation along y axis.
Definition: Descriptors.hpp:580
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: ClWorkloadUtils.hpp:36
armnn::Convolution2dDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:582
armnn::GetConvolutionMethodString
std::string GetConvolutionMethodString(arm_compute::ConvolutionMethod &convolutionMethod)
Definition: ClWorkloadUtils.hpp:46
armnn::Convolution2dDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:584
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::BaseWorkload< Convolution2dQueueDescriptor >::GetGuid
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:67
armnn::BaseWorkload< Convolution2dQueueDescriptor >::m_Data
Convolution2dQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::RunClFunction
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
Definition: ClWorkloadUtils.hpp:168
armnn::Convolution2dDescriptor::m_DilationX
uint32_t m_DilationX
Dilation along x axis.
Definition: Descriptors.hpp:578
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::DataLayout::NCHW
@ NCHW