ArmNN
 21.08
NeonFullyConnectedWorkload Class Reference

#include <NeonFullyConnectedWorkload.hpp>

Inheritance diagram for NeonFullyConnectedWorkload:
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 BaseWorkload< FullyConnectedQueueDescriptor >
 BaseWorkload (const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info)
 
void ExecuteAsync (WorkingMemDescriptor &workingMemDescriptor) override
 
void PostAllocationConfigure () override
 
const FullyConnectedQueueDescriptorGetData () const
 
profiling::ProfilingGuid GetGuid () const final
 
- Public Member Functions inherited from IWorkload
virtual ~IWorkload ()
 
virtual void RegisterDebugCallback (const DebugCallbackFunction &)
 

Additional Inherited Members

- Protected Attributes inherited from BaseWorkload< FullyConnectedQueueDescriptor >
FullyConnectedQueueDescriptor m_Data
 
const profiling::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 53 of file NeonFullyConnectedWorkload.cpp.

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

56  : BaseWorkload<FullyConnectedQueueDescriptor>(descriptor, info)
57 {
58  m_Data.ValidateInputsOutputs("NeonFullyConnectedWorkload", 1, 1);
59 
60  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
61  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
62 
63  m_WeightsTensor = std::make_unique<arm_compute::Tensor>();
64  BuildArmComputeTensor(*m_WeightsTensor, m_Data.m_Weight->GetTensorInfo());
65 
67  {
68  m_BiasesTensor = std::make_unique<arm_compute::Tensor>();
69  BuildArmComputeTensor(*m_BiasesTensor, m_Data.m_Bias->GetTensorInfo());
70  }
71 
72  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
73 
74  arm_compute::FullyConnectedLayerInfo fc_info =
75  ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor.m_Parameters, activationInfo);
76 
77  auto layer = std::make_unique<arm_compute::NEFullyConnectedLayer>(memoryManager);
78  layer->configure(&input, m_WeightsTensor.get(), m_BiasesTensor.get(), &output, fc_info);
79  m_FullyConnectedLayer.reset(layer.release());
80 
81  // Allocate
83  {
85  }
86  else
87  {
89  }
90 
91  if (m_BiasesTensor)
92  {
94  {
96  }
97  else
98  {
100  }
101  }
102 
103  // Add details for profiling output
104  WorkloadInfo detailsInfo;
105 
106  detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos;
107  detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos;
108  detailsInfo.m_WeightsTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Weight->GetTensorInfo());
109  if (descriptor.m_Parameters.m_BiasEnabled)
110  {
111  detailsInfo.m_BiasTensorInfo = armnn::Optional<armnn::TensorInfo>(descriptor.m_Bias->GetTensorInfo());
112  }
113 
114  // Report Profiling Details
115  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonFullyConnectedWorkload_Construct",
116  descriptor.m_Parameters,
117  detailsInfo,
118  this->GetGuid());
119 
120  // Force Compute Library to perform the necessary copying and reshaping, after which
121  // delete all the input tensors that will no longer be needed
122  m_FullyConnectedLayer->prepare();
123  FreeUnusedTensors();
124 }
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
DataType GetDataType() const
Definition: Tensor.hpp:198
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:226
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 126 of file NeonFullyConnectedWorkload.cpp.

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

127 {
128  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonFullyConnectedWorkload_Execute", this->GetGuid());
129  m_FullyConnectedLayer->run();
130 }
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)

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