ArmNN
 24.02
NeonFullyConnectedWorkload Class Reference

#include <NeonFullyConnectedWorkload.hpp>

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

Public Member Functions

 NeonFullyConnectedWorkload (const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
 
virtual void Execute () const override
 
- Public Member Functions inherited from NeonBaseWorkload< FullyConnectedQueueDescriptor >
 NeonBaseWorkload (const FullyConnectedQueueDescriptor &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< FullyConnectedQueueDescriptor >
 BaseWorkload (const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info)
 
virtual const std::string & GetName () const override
 
void ExecuteAsync (ExecutionData &executionData) override
 
void PostAllocationConfigure () override
 
const FullyConnectedQueueDescriptorGetData () 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< FullyConnectedQueueDescriptor >
virtual void Reconfigure ()
 
- Protected Attributes inherited from BaseWorkload< FullyConnectedQueueDescriptor >
FullyConnectedQueueDescriptor m_Data
 
const arm::pipe::ProfilingGuid m_Guid
 
const std::string m_Name
 

Detailed Description

Definition at line 27 of file NeonFullyConnectedWorkload.hpp.

Constructor & Destructor Documentation

◆ NeonFullyConnectedWorkload()

NeonFullyConnectedWorkload ( const FullyConnectedQueueDescriptor descriptor,
const WorkloadInfo info,
std::shared_ptr< arm_compute::MemoryManagerOnDemand > &  memoryManager 
)

Definition at line 55 of file NeonFullyConnectedWorkload.cpp.

58  : NeonBaseWorkload<FullyConnectedQueueDescriptor>(descriptor, info)
59 {
60  m_Data.ValidateInputsOutputs("NeonFullyConnectedWorkload", descriptor.m_Parameters.GetNumInputs(), 1);
61 
62  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
63  arm_compute::ITensor& weights = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
64  m_WeightsTensorInfo = info.m_InputTensorInfos[1];
65  weights.info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
66  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
67  if (m_WeightsTensorInfo.IsConstant())
68  {
69  // Copy the weights' tensor into arm_compute tensor.
70  m_WeightsTensor = std::make_unique<arm_compute::Tensor>();
71  BuildArmComputeTensor(*m_WeightsTensor, m_WeightsTensorInfo);
72  m_WeightsTensor->info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
73  }
74 
76  {
77  // Copy the biases tensor into arm_compute tensor.
78  m_BiasesTensor = std::make_unique<arm_compute::Tensor>();
79  m_BiasesTensorInfo = info.m_InputTensorInfos[2];
80  BuildArmComputeTensor(*m_BiasesTensor, m_BiasesTensorInfo);
81  m_BiasesTensor->info()->set_are_values_constant(m_BiasesTensorInfo.IsConstant());
82  }
83 
84  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
85  arm_compute::FullyConnectedLayerInfo fc_info =
86  ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor.m_Parameters, activationInfo);
87 
88  auto layer = std::make_unique<arm_compute::NEFullyConnectedLayer>(memoryManager);
89  if (m_WeightsTensorInfo.IsConstant())
90  {
91  layer->configure(&input, m_WeightsTensor.get(), m_BiasesTensor.get(), &output, fc_info);
92  }
93  else
94  {
95  layer->configure(&input, &weights, m_BiasesTensor.get(), &output, fc_info);
96  }
97  m_FullyConnectedLayer.reset(layer.release());
98 
99  // Add details for profiling output
100  WorkloadInfo detailsInfo;
101 
102  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
103  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
104 
105  // Report Profiling Details
106  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonFullyConnectedWorkload_Construct",
107  descriptor.m_Parameters,
108  detailsInfo,
109  this->GetGuid());
110 }

References FullyConnectedDescriptor::GetNumInputs(), armnn::info, TensorInfo::IsConstant(), BaseWorkload< FullyConnectedQueueDescriptor >::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 112 of file NeonFullyConnectedWorkload.cpp.

113 {
114  ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonFullyConnectedWorkload_Execute");
115  // The constant tensors may not be fully in place until the workload is Executed
116  if (!prepared)
117  {
118  if (m_WeightsTensorInfo.IsConstant())
119  {
120  InitializeArmComputeTensorData(*m_WeightsTensor, m_WeightsTensorInfo, m_Data.m_Inputs[1]);
121  m_WeightsTensor->info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
122  }
123 
125  {
126  InitializeArmComputeTensorData(*m_BiasesTensor, m_BiasesTensorInfo, m_Data.m_Inputs[2]);
127  m_BiasesTensor->info()->set_are_values_constant(m_BiasesTensorInfo.IsConstant());
128  }
129  if (m_WeightsTensorInfo.IsConstant())
130  {
131  FreeTensorIfUnused(m_WeightsTensor);
132  }
133  if (m_BiasesTensorInfo.IsConstant())
134  {
135  FreeTensorIfUnused(m_BiasesTensor);
136  }
137  prepared = true;
138  }
139  m_FullyConnectedLayer->run();
140 }

References ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID, armnn::InitializeArmComputeTensorData(), TensorInfo::IsConstant(), FullyConnectedDescriptor::m_BiasEnabled, BaseWorkload< FullyConnectedQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.


The documentation for this class was generated from the following files:
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::TensorInfo::IsConstant
bool IsConstant() const
Definition: Tensor.cpp:509
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::FullyConnectedDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:526
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< FullyConnectedQueueDescriptor >::m_Data
FullyConnectedQueueDescriptor m_Data
Definition: Workload.hpp:89
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::ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
Definition: ArmComputeUtils.hpp:194
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26