ArmNN
 24.08
NeonConvolution2dWorkload Class Reference

#include <NeonConvolution2dWorkload.hpp>

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

Public Member Functions

 NeonConvolution2dWorkload (const Convolution2dQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager, const bool isFastMathENabled=false)
 
void Execute () const override
 
arm_compute::ConvolutionMethod GetConvolutionMethod () const
 
- Public Member Functions inherited from NeonBaseWorkload< Convolution2dQueueDescriptor >
 NeonBaseWorkload (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 bool SupportsTensorHandleReplacement () const =0
 
virtual const std::string & GetName () const =0
 
virtual void RegisterDebugCallback (const DebugCallbackFunction &)
 
virtual armnn::Optional< armnn::MemoryRequirementsGetMemoryRequirements ()
 

Additional Inherited Members

- Protected Member Functions inherited from NeonBaseWorkload< Convolution2dQueueDescriptor >
virtual void Reconfigure ()
 
- 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 27 of file NeonConvolution2dWorkload.hpp.

Constructor & Destructor Documentation

◆ NeonConvolution2dWorkload()

NeonConvolution2dWorkload ( const Convolution2dQueueDescriptor descriptor,
const WorkloadInfo info,
std::shared_ptr< arm_compute::MemoryManagerOnDemand > &  memoryManager,
const bool  isFastMathENabled = false 
)

Definition at line 71 of file NeonConvolution2dWorkload.cpp.

76  : NeonBaseWorkload<Convolution2dQueueDescriptor>(descriptor, info)
77 {
78  using arm_compute::NEConvolutionLayer;
79 
80  uint32_t numInputs = m_Data.m_Parameters.m_BiasEnabled ? 3: 2;
81  m_Data.ValidateInputsOutputs("NeonConvolution2dWorkload", numInputs, 1);
82 
83  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
84  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
85 
86  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
87  input.info()->set_data_layout(aclDataLayout);
88  output.info()->set_data_layout(aclDataLayout);
89 
90  m_KernelTensor = std::make_unique<arm_compute::Tensor>();
91  BuildArmComputeTensor(*m_KernelTensor, info.m_InputTensorInfos[1], m_Data.m_Parameters.m_DataLayout);
92  m_KernelTensor->info()->set_are_values_constant(info.m_InputTensorInfos[1].IsConstant());
94  {
95  m_BiasTensor = std::make_unique<arm_compute::Tensor>();
96  BuildArmComputeTensor(*m_BiasTensor, info.m_InputTensorInfos[2], m_Data.m_Parameters.m_DataLayout);
97  m_BiasTensor->info()->set_are_values_constant(info.m_InputTensorInfos[2].IsConstant());
98  }
99 
100  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
101 
102  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(m_Data.m_Parameters.m_DilationX,
104 
105  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
106 
107  auto convolutionLayer = std::make_unique<arm_compute::NEConvolutionLayer>(memoryManager);
108  convolutionLayer->configure(&input,
109  m_KernelTensor.get(),
110  m_BiasTensor.get(),
111  &output,
112  padStrideInfo,
113  arm_compute::WeightsInfo(),
114  aclDilationInfo,
115  activationInfo,
116  isFastMathEnabled);
117 
118  m_ConvolutionMethod =
119  convolutionLayer->get_convolution_method(input.info(),
120  m_KernelTensor->info(),
121  output.info(),
122  padStrideInfo,
123  arm_compute::WeightsInfo(),
124  aclDilationInfo,
125  activationInfo,
126  isFastMathEnabled);
127 
128  // Add details for profiling output
129  WorkloadInfo detailsInfo;
130 
131  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
132  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
133  detailsInfo.m_ConvolutionMethod = armnn::Optional<std::string>(GetConvolutionMethodString(m_ConvolutionMethod));
134 
135  // Report Profiling Details
136  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonConvolution2dWorkload_Construct",
137  descriptor.m_Parameters,
138  detailsInfo,
139  GetGuid());
140 
141  m_ConvolutionLayer.reset(convolutionLayer.release());
142  m_KernelTensorInfo = info.m_InputTensorInfos[1];
143 
145  {
146  m_BiasTensorInfo = info.m_InputTensorInfos[2];
147  }
148 }

References armnn::info, Convolution2dDescriptor::m_BiasEnabled, BaseWorkload< Convolution2dQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, QueueDescriptor::m_Outputs, QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters, and QueueDescriptor::ValidateInputsOutputs().

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 150 of file NeonConvolution2dWorkload.cpp.

151 {
152  ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonConvolution2dWorkload_Execute");
153  // The constant tensors may not be fully in place until the workload is Executed
154  if (!prepared)
155  {
156  InitializeArmComputeTensorData(*m_KernelTensor, m_KernelTensorInfo, m_Data.m_Inputs[1]);
157 
159  {
160  InitializeArmComputeTensorData(*m_BiasTensor, m_BiasTensorInfo, m_Data.m_Inputs[2]);
161  }
162  m_ConvolutionLayer->prepare();
163  FreeTensorIfUnused(m_KernelTensor);
164  FreeTensorIfUnused(m_BiasTensor);
165  prepared = true;
166  }
167  m_ConvolutionLayer->run();
168 }

References ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID, armnn::InitializeArmComputeTensorData(), Convolution2dDescriptor::m_BiasEnabled, BaseWorkload< Convolution2dQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

◆ GetConvolutionMethod()

arm_compute::ConvolutionMethod GetConvolutionMethod ( ) const

Definition at line 170 of file NeonConvolution2dWorkload.cpp.

171 {
172  return m_ConvolutionMethod;
173 }

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
armnn::Convolution2dDescriptor::m_DilationY
uint32_t m_DilationY
Dilation along y axis.
Definition: Descriptors.hpp:580
armnn::InitializeArmComputeTensorData
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, TensorInfo tensorInfo, const ITensorHandle *handle)
Definition: NeonWorkloadUtils.hpp:69
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
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::Convolution2dDescriptor::m_DilationX
uint32_t m_DilationX
Dilation along x axis.
Definition: Descriptors.hpp:578
ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: NeonWorkloadUtils.hpp:33
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26