ArmNN
 23.02
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", 1, 1);
67 
68  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
69  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
70 
71  // Copy the weights' tensor into arm_compute tensor.
72  m_WeightsTensor = std::make_unique<arm_compute::Tensor>();
73  m_WeightsTensorInfo = info.m_InputTensorInfos[1];
74  BuildArmComputeTensor(*m_WeightsTensor, m_WeightsTensorInfo);
75 
77  {
78  // Copy the biases tensor into arm_compute tensor.
79  m_BiasesTensor = std::make_unique<arm_compute::Tensor>();
80  m_BiasesTensorInfo = info.m_InputTensorInfos[2];
81  BuildArmComputeTensor(*m_BiasesTensor, m_BiasesTensorInfo);
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  layer->configure(&input, m_WeightsTensor.get(), m_BiasesTensor.get(), &output, fc_info);
90  m_FullyConnectedLayer.reset(layer.release());
91 
92  // Add details for profiling output
93  WorkloadInfo detailsInfo;
94 
95  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
96  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
97  detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(info.m_InputTensorInfos[1]);
98  if (descriptor.m_Parameters.m_BiasEnabled)
99  {
100  detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(info.m_InputTensorInfos[2]);
101  }
102 
103  // Report Profiling Details
104  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonFullyConnectedWorkload_Construct",
105  descriptor.m_Parameters,
106  detailsInfo,
107  this->GetGuid());
108 
109  // Force Compute Library to perform the necessary copying and reshaping.
110 }

References armnn::info, BaseWorkload< FullyConnectedQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, QueueDescriptor::m_Outputs, 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_GUID("NeonFullyConnectedWorkload_Execute", this->GetGuid());
115  // The constant tensors may not be fully in place until the workload is Executed
116  if (!prepared)
117  {
118  InitializeArmComputeTensorData(*m_WeightsTensor, m_WeightsTensorInfo, m_Data.m_Inputs[1]);
119 
121  {
122  InitializeArmComputeTensorData(*m_BiasesTensor, m_BiasesTensorInfo, m_Data.m_Inputs[2]);
123  }
124  m_FullyConnectedLayer->prepare();
125  FreeTensorIfUnused(m_WeightsTensor);
126  FreeTensorIfUnused(m_BiasesTensor);
127  prepared = true;
128  }
129  m_FullyConnectedLayer->run();
130 }

References ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID, BaseWorkload< FullyConnectedQueueDescriptor >::GetGuid(), armnn::InitializeArmComputeTensorData(), 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:494
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:475
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::ConvertAdditionalInfoToAclActivationLayerInfo
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
Definition: ArmComputeUtils.hpp:103
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
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