ArmNN
 20.11
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 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 >
const 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 62 of file NeonFullyConnectedWorkload.cpp.

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

64  : BaseWorkload<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  m_WeightsTensor = std::make_unique<arm_compute::Tensor>();
72  BuildArmComputeTensor(*m_WeightsTensor, m_Data.m_Weight->GetTensorInfo());
73 
75  {
76  m_BiasesTensor = std::make_unique<arm_compute::Tensor>();
77  BuildArmComputeTensor(*m_BiasesTensor, m_Data.m_Bias->GetTensorInfo());
78  }
79 
80  const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor);
81 
82  arm_compute::FullyConnectedLayerInfo fc_info =
83  ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor.m_Parameters, activationInfo);
84 
85  auto layer = std::make_unique<arm_compute::NEFullyConnectedLayer>(memoryManager);
86  layer->configure(&input, m_WeightsTensor.get(), m_BiasesTensor.get(), &output, fc_info);
87  m_FullyConnectedLayer.reset(layer.release());
88 
89  // Allocate
91  {
93  }
94  else
95  {
97  }
98 
99  if (m_BiasesTensor)
100  {
102  {
103  InitializeArmComputeTensorData(*m_BiasesTensor, m_Data.m_Bias);
104  }
105  else
106  {
107  InitializeArmComputeTensorData(*m_BiasesTensor, m_Data.m_Bias);
108  }
109  }
110 
111  // Force Compute Library to perform the necessary copying and reshaping, after which
112  // delete all the input tensors that will no longer be needed
113  m_FullyConnectedLayer->prepare();
114  FreeUnusedTensors();
115 }
const ConstCpuTensorHandle * m_Weight
const FullyConnectedQueueDescriptor m_Data
Definition: Workload.hpp:46
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
DataType GetDataType() const
Definition: Tensor.hpp:194
bool m_BiasEnabled
Enable/disable bias.
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, const ConstCpuTensorHandle *handle)
std::vector< ITensorHandle * > m_Outputs
std::vector< ITensorHandle * > m_Inputs
const ConstCpuTensorHandle * m_Bias
const TensorInfo & GetTensorInfo() const

Member Function Documentation

◆ Execute()

void Execute ( ) const
overridevirtual

Implements IWorkload.

Definition at line 117 of file NeonFullyConnectedWorkload.cpp.

References ARMNN_SCOPED_PROFILING_EVENT_NEON.

118 {
119  ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonFullyConnectedWorkload_Execute");
120  m_FullyConnectedLayer->run();
121 }
#define ARMNN_SCOPED_PROFILING_EVENT_NEON(name)

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