ArmNN
 24.02
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  // We assume here that NeonConvolution2dWorkloadValidate has been called before the constructor.
99  ARMNN_ASSERT(info.m_InputTensorInfos[2].IsConstant() == true);
100  }
101 
102  arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(m_Data.m_Parameters);
103 
104  const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(m_Data.m_Parameters.m_DilationX,
106 
107  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
108 
109  auto convolutionLayer = std::make_unique<arm_compute::NEConvolutionLayer>(memoryManager);
110  convolutionLayer->configure(&input,
111  m_KernelTensor.get(),
112  m_BiasTensor.get(),
113  &output,
114  padStrideInfo,
115  arm_compute::WeightsInfo(),
116  aclDilationInfo,
117  activationInfo,
118  isFastMathEnabled);
119 
120  m_ConvolutionMethod =
121  convolutionLayer->get_convolution_method(input.info(),
122  m_KernelTensor->info(),
123  output.info(),
124  padStrideInfo,
125  arm_compute::WeightsInfo(),
126  aclDilationInfo,
127  activationInfo,
128  isFastMathEnabled);
129 
130  // Add details for profiling output
131  WorkloadInfo detailsInfo;
132 
133  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
134  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
135  detailsInfo.m_ConvolutionMethod = armnn::Optional<std::string>(GetConvolutionMethodString(m_ConvolutionMethod));
136 
137  // Report Profiling Details
138  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonConvolution2dWorkload_Construct",
139  descriptor.m_Parameters,
140  detailsInfo,
141  GetGuid());
142 
143  m_ConvolutionLayer.reset(convolutionLayer.release());
144 
145  ARMNN_ASSERT(m_ConvolutionLayer);
146  m_KernelTensorInfo = info.m_InputTensorInfos[1];
147 
149  {
150  m_BiasTensorInfo = info.m_InputTensorInfos[2];
151  }
152 }

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 154 of file NeonConvolution2dWorkload.cpp.

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

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 174 of file NeonConvolution2dWorkload.cpp.

175 {
176  return m_ConvolutionMethod;
177 }

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
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:68
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:32
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26