ArmNN
 22.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 (WorkingMemDescriptor &workingMemDescriptor) 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 void RegisterDebugCallback (const DebugCallbackFunction &)
 

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

References BaseWorkload< FullyConnectedQueueDescriptor >::m_Data, QueueDescriptor::m_Inputs, QueueDescriptor::m_Outputs, and QueueDescriptor::ValidateInputsOutputs().

72  : NeonBaseWorkload<FullyConnectedQueueDescriptor>(descriptor, info)
73 {
74  m_Data.ValidateInputsOutputs("NeonFullyConnectedWorkload", 1, 1);
75 
76  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
77  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
78 
79  // Copy the weights' tensor into arm_compute tensor.
80  m_WeightsTensor = std::make_unique<arm_compute::Tensor>();
81  BuildArmComputeTensor(*m_WeightsTensor, m_Data.m_Weight->GetTensorInfo());
83 
85  {
86  // Copy the biases tensor into arm_compute tensor.
87  m_BiasesTensor = std::make_unique<arm_compute::Tensor>();
88  BuildArmComputeTensor(*m_BiasesTensor, m_Data.m_Bias->GetTensorInfo());
90  }
91 
92  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
93  arm_compute::FullyConnectedLayerInfo fc_info =
94  ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor.m_Parameters, activationInfo);
95 
96  auto layer = std::make_unique<arm_compute::NEFullyConnectedLayer>(memoryManager);
97  layer->configure(&input, m_WeightsTensor.get(), m_BiasesTensor.get(), &output, fc_info);
98  m_FullyConnectedLayer.reset(layer.release());
99 
100  // Add details for profiling output
101  WorkloadInfo detailsInfo;
102 
103  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
104  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
105  detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Weight->GetTensorInfo());
106  if (descriptor.m_Parameters.m_BiasEnabled)
107  {
108  detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Bias->GetTensorInfo());
109  }
110 
111  // Report Profiling Details
112  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonFullyConnectedWorkload_Construct",
113  descriptor.m_Parameters,
114  detailsInfo,
115  this->GetGuid());
116 
117  // Force Compute Library to perform the necessary copying and reshaping.
118  m_FullyConnectedLayer->prepare();
119  FreeTensorIfUnused(m_WeightsTensor);
120  FreeTensorIfUnused(m_BiasesTensor);
121 }
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
const ConstTensorHandle * m_Bias
const TensorInfo & GetTensorInfo() const
bool m_BiasEnabled
Enable/disable bias.
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
const ConstTensorHandle * m_Weight
std::vector< ITensorHandle * > m_Outputs
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, const ConstTensorHandle *handle)
std::vector< ITensorHandle * > m_Inputs

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 123 of file NeonFullyConnectedWorkload.cpp.

References ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID, and BaseWorkload< FullyConnectedQueueDescriptor >::GetGuid().

124 {
125  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonFullyConnectedWorkload_Execute", this->GetGuid());
126  m_FullyConnectedLayer->run();
127 }
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:59
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)

The documentation for this class was generated from the following files: