ArmNN
 24.08
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_THROW_INVALIDARG_MSG_IF_FALSE(info.m_InputTensorInfos[2].IsConstant() == true,
103  "The bias tensor must be constant.");
104  m_BiasProxy = std::make_unique<ICLTensorProxy>(&bias);
105  }
106 
107  // Create Proxy tensor and set the initial tensor handle to it
108  m_InputProxy = std::make_unique<ICLTensorProxy>(&input);
109  m_OutputProxy = std::make_unique<ICLTensorProxy>(&output);
110  m_WeightsProxy = std::make_unique<ICLTensorProxy>(&weights);
111 
112  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
113  input.info()->set_data_layout(aclDataLayout);
114  output.info()->set_data_layout(aclDataLayout);
115  weights.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  {
122  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClConvolution2dWorkload_configure");
123  m_ConvolutionLayer.configure(clCompileContext,
124  m_InputProxy.get(),
125  m_WeightsProxy.get(),
126  m_BiasProxy.get(),
127  m_OutputProxy.get(),
128  padStrideInfo,
129  arm_compute::WeightsInfo(),
130  aclDilationInfo,
131  activationInfo,
132  isFastMathEnabled);
133  }
134 
135  m_ConvolutionMethod =
136  m_ConvolutionLayer.get_convolution_method(input.info(),
137  weights.info(),
138  output.info(),
139  padStrideInfo,
140  arm_compute::WeightsInfo(),
141  activationInfo,
142  arm_compute::CLScheduler::get().target(),
143  aclDilationInfo,
144  isFastMathEnabled);
145 
146  // Add details for profiling output
147  WorkloadInfo detailsInfo;
148 
149  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
150  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
151  detailsInfo.m_ConvolutionMethod = armnn::Optional<std::string>(GetConvolutionMethodString(m_ConvolutionMethod));
152 
153  // Report Profiling Details
154  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClConvolution2dWorkload_Construct",
155  descriptor.m_Parameters,
156  detailsInfo,
157  GetGuid());
158 }

References ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID, and armnn::info.

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 160 of file ClConvolution2dWorkload.cpp.

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

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

◆ GetConvolutionMethod()

arm_compute::ConvolutionMethod GetConvolutionMethod ( ) const

Definition at line 166 of file ClConvolution2dWorkload.cpp.

167 {
168  return m_ConvolutionMethod;
169 }

◆ Reconfigure()

void Reconfigure ( )
overrideprotectedvirtual

Reimplemented from ClBaseWorkload< Convolution2dQueueDescriptor >.

Definition at line 171 of file ClConvolution2dWorkload.cpp.

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

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::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:447
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:167
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
ARMNN_THROW_INVALIDARG_MSG_IF_FALSE
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
Definition: Exceptions.hpp:210