ArmNN
 23.05
NeonFullyConnectedWorkload Class Reference

#include <NeonFullyConnectedWorkload.hpp>

Inheritance diagram for NeonFullyConnectedWorkload:
NeonBaseWorkload< FullyConnectedQueueDescriptor > BaseWorkload< FullyConnectedQueueDescriptor > IWorkload

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)
 
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 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
 

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 61 of file NeonFullyConnectedWorkload.cpp.

64  : NeonBaseWorkload<FullyConnectedQueueDescriptor>(descriptor, info)
65 {
66  m_Data.ValidateInputsOutputs("NeonFullyConnectedWorkload", descriptor.m_Parameters.GetNumInputs(), 1);
67 
68  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
69  arm_compute::ITensor& weights = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor();
70  m_WeightsTensorInfo = info.m_InputTensorInfos[1];
71  weights.info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
72  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
73  if (m_WeightsTensorInfo.IsConstant())
74  {
75  // Copy the weights' tensor into arm_compute tensor.
76  m_WeightsTensor = std::make_unique<arm_compute::Tensor>();
77  BuildArmComputeTensor(*m_WeightsTensor, m_WeightsTensorInfo);
78  m_WeightsTensor->info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
79  }
80 
82  {
83  // Copy the biases tensor into arm_compute tensor.
84  m_BiasesTensor = std::make_unique<arm_compute::Tensor>();
85  m_BiasesTensorInfo = info.m_InputTensorInfos[2];
86  BuildArmComputeTensor(*m_BiasesTensor, m_BiasesTensorInfo);
87  m_BiasesTensor->info()->set_are_values_constant(m_BiasesTensorInfo.IsConstant());
88 
89  // We do not support dynamic bias
90  ARMNN_ASSERT(m_BiasesTensorInfo.IsConstant() == true);
91  }
92 
93  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
94  arm_compute::FullyConnectedLayerInfo fc_info =
95  ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor.m_Parameters, activationInfo);
96 
97  auto layer = std::make_unique<arm_compute::NEFullyConnectedLayer>(memoryManager);
98  if (m_WeightsTensorInfo.IsConstant())
99  {
100  layer->configure(&input, m_WeightsTensor.get(), m_BiasesTensor.get(), &output, fc_info);
101  }
102  else
103  {
104  layer->configure(&input, &weights, m_BiasesTensor.get(), &output, fc_info);
105  }
106  m_FullyConnectedLayer.reset(layer.release());
107 
108  // Add details for profiling output
109  WorkloadInfo detailsInfo;
110 
111  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
112  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
113  detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(info.m_InputTensorInfos[1]);
114  if (descriptor.m_Parameters.m_BiasEnabled)
115  {
116  detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(info.m_InputTensorInfos[2]);
117  }
118 
119  // Report Profiling Details
120  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonFullyConnectedWorkload_Construct",
121  descriptor.m_Parameters,
122  detailsInfo,
123  this->GetGuid());
124 }

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 126 of file NeonFullyConnectedWorkload.cpp.

127 {
128  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonFullyConnectedWorkload_Execute", this->GetGuid());
129  // The constant tensors may not be fully in place until the workload is Executed
130  if (!prepared)
131  {
132  if (m_WeightsTensorInfo.IsConstant())
133  {
134  InitializeArmComputeTensorData(*m_WeightsTensor, m_WeightsTensorInfo, m_Data.m_Inputs[1]);
135  m_WeightsTensor->info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
136  }
137 
139  {
140  InitializeArmComputeTensorData(*m_BiasesTensor, m_BiasesTensorInfo, m_Data.m_Inputs[2]);
141  m_BiasesTensor->info()->set_are_values_constant(m_BiasesTensorInfo.IsConstant());
142  }
143  if (m_WeightsTensorInfo.IsConstant())
144  {
145  FreeTensorIfUnused(m_WeightsTensor);
146  }
147  if (m_BiasesTensorInfo.IsConstant())
148  {
149  FreeTensorIfUnused(m_BiasesTensor);
150  }
151  prepared = true;
152  }
153  m_FullyConnectedLayer->run();
154 }

References ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID, BaseWorkload< FullyConnectedQueueDescriptor >::GetGuid(), 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::FullyConnectedDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:514
armnn::BaseWorkload< FullyConnectedQueueDescriptor >::GetGuid
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:61
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:472
armnn::BaseWorkload< FullyConnectedQueueDescriptor >::m_Data
FullyConnectedQueueDescriptor m_Data
Definition: Workload.hpp:83
armnn::InitializeArmComputeTensorData
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, TensorInfo tensorInfo, const ITensorHandle *handle)
Definition: NeonWorkloadUtils.hpp:60
armnn::ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
Definition: ArmComputeUtils.hpp:192
ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)
Definition: NeonWorkloadUtils.hpp:24
armnn::TensorInfo::IsConstant
bool IsConstant() const
Definition: Tensor.cpp:509
armnn::ConvertAdditionalInfoToAclActivationLayerInfo
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
Definition: ArmComputeUtils.hpp:103
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
ARMNN_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::Optional< armnn::TensorInfo >
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::BoostLogSeverityMapping::info
@ info