17 #include <arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h> 21 using namespace armcomputetensorutils;
37 "Arm NN NeonFullyConnectedWorkload does not support non constant weights."};
39 const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input);
40 const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output);
41 arm_compute::TensorInfo aclWeights = BuildArmComputeTensorInfo(weights);
42 aclWeights.set_are_values_constant(weights.
IsConstant());
44 arm_compute::TensorInfo aclBiases;
45 arm_compute::TensorInfo* optionalAclBiases =
nullptr;
50 if (!biases.
value().IsConstant())
53 "Arm NN NeonFullyConnectedWorkload does not support non constant bias."};
55 aclBiases = BuildArmComputeTensorInfo(biases.
value());
56 aclBiases.set_are_values_constant(biases.
value().IsConstant());
57 optionalAclBiases = &aclBiases;
60 const arm_compute::FullyConnectedLayerInfo fullyConnectedLayerInfo =
62 return arm_compute::NEFullyConnectedLayer::validate(&aclInput,
66 fullyConnectedLayerInfo);
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();
80 m_WeightsTensor = std::make_unique<arm_compute::Tensor>();
87 m_BiasesTensor = std::make_unique<arm_compute::Tensor>();
93 arm_compute::FullyConnectedLayerInfo fc_info =
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());
118 m_FullyConnectedLayer->prepare();
119 FreeTensorIfUnused(m_WeightsTensor);
120 FreeTensorIfUnused(m_BiasesTensor);
126 m_FullyConnectedLayer->run();
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
arm::pipe::ProfilingGuid GetGuid() const final
arm_compute::Status NeonFullyConnectedWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const Optional< TensorInfo > &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
NeonFullyConnectedWorkload(const FullyConnectedQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
const ConstTensorHandle * m_Bias
LayerDescriptor m_Parameters
std::shared_ptr< arm_compute::MemoryManagerOnDemand > ACLMemManagerOnDemand
const TensorInfo & GetTensorInfo() const
std::vector< TensorInfo > m_InputTensorInfos
FullyConnectedQueueDescriptor m_Data
bool has_value() const noexcept
A FullyConnectedDescriptor for the FullyConnectedLayer.
bool m_BiasEnabled
Enable/disable bias.
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
#define ARMNN_ASSERT(COND)
std::vector< TensorInfo > m_OutputTensorInfos
const ConstTensorHandle * m_Weight
An ActivationDescriptor for the ActivationLayer.
Optional< TensorInfo > m_BiasTensorInfo
std::vector< ITensorHandle * > m_Outputs
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
void InitializeArmComputeTensorData(arm_compute::Tensor &tensor, const ConstTensorHandle *handle)
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
virtual void Execute() const override
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)
Optional< TensorInfo > m_WeightsTensorInfo