17#include <arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h>
21using namespace armcomputetensorutils;
31 const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
32 const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
33 arm_compute::TensorInfo aclWeights = BuildArmComputeTensorInfo(weights);
34 aclWeights.set_are_values_constant(weights.
IsConstant());
36 arm_compute::TensorInfo aclBiases;
37 arm_compute::TensorInfo* optionalAclBiases =
nullptr;
42 "NeonFullyConnectedWorkload: Bias was enabled in the descriptor but no value was supplied.");
43 aclBiases = BuildArmComputeTensorInfo(biases.
value());
44 aclBiases.set_are_values_constant(biases.
value().IsConstant());
45 optionalAclBiases = &aclBiases;
48 const arm_compute::FullyConnectedLayerInfo fullyConnectedLayerInfo =
50 return arm_compute::NEFullyConnectedLayer::validate(&aclInput,
54 fullyConnectedLayerInfo);
66 m_WeightsTensorInfo =
info.m_InputTensorInfos[1];
67 weights.info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
69 if (m_WeightsTensorInfo.IsConstant())
72 m_WeightsTensor = std::make_unique<arm_compute::Tensor>();
73 BuildArmComputeTensor(*m_WeightsTensor, m_WeightsTensorInfo);
74 m_WeightsTensor->info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
77 if (
m_Data.m_Parameters.m_BiasEnabled)
80 m_BiasesTensor = std::make_unique<arm_compute::Tensor>();
81 m_BiasesTensorInfo = info.m_InputTensorInfos[2];
82 BuildArmComputeTensor(*m_BiasesTensor, m_BiasesTensorInfo);
83 m_BiasesTensor->info()->set_are_values_constant(m_BiasesTensorInfo.IsConstant());
87 arm_compute::FullyConnectedLayerInfo fc_info =
90 auto layer = std::make_unique<arm_compute::NEFullyConnectedLayer>(memoryManager);
91 if (m_WeightsTensorInfo.IsConstant())
93 layer->configure(&input, m_WeightsTensor.get(), m_BiasesTensor.get(), &output, fc_info);
97 layer->configure(&input, &weights, m_BiasesTensor.get(), &output, fc_info);
99 m_FullyConnectedLayer.reset(layer.release());
120 if (m_WeightsTensorInfo.IsConstant())
123 m_WeightsTensor->info()->set_are_values_constant(m_WeightsTensorInfo.IsConstant());
126 if (
m_Data.m_Parameters.m_BiasEnabled)
129 m_BiasesTensor->info()->set_are_values_constant(m_BiasesTensorInfo.IsConstant());
131 if (m_WeightsTensorInfo.IsConstant())
133 FreeTensorIfUnused(m_WeightsTensor);
135 if (m_BiasesTensorInfo.IsConstant())
137 FreeTensorIfUnused(m_BiasesTensor);
141 m_FullyConnectedLayer->run();
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
FullyConnectedQueueDescriptor m_Data
NeonBaseWorkload(const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info)
NeonFullyConnectedWorkload(const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
virtual void Execute() const override
bool has_value() const noexcept
Copyright (c) 2021 ARM Limited and Contributors.
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
DestType PolymorphicDowncast(SourceType *value)
Polymorphic downcast for build in pointers only.
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, TensorInfo tensorInfo, const ITensorHandle *handle)
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
arm_compute::Status NeonFullyConnectedWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const Optional< TensorInfo > &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
std::shared_ptr< arm_compute::MemoryManagerOnDemand > ACLMemManagerOnDemand
An ActivationDescriptor for the ActivationLayer.
A FullyConnectedDescriptor for the FullyConnectedLayer.
uint32_t GetNumInputs() const
Get the number of inputs.
bool m_BiasEnabled
Enable/disable bias.
LayerDescriptor m_Parameters
Contains information about TensorInfos of a layer.
std::vector< TensorInfo > m_OutputTensorInfos
std::vector< TensorInfo > m_InputTensorInfos