17 #include <arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h>
21 using 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);
64 arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(
m_Data.
m_Inputs[0])->GetTensor();
65 arm_compute::ITensor& weights = PolymorphicDowncast<IAclTensorHandle*>(
m_Data.
m_Inputs[1])->GetTensor();
66 m_WeightsTensorInfo =
info.m_InputTensorInfos[1];
67 weights.info()->set_are_values_constant(m_WeightsTensorInfo.
IsConstant());
68 arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(
m_Data.
m_Outputs[0])->GetTensor();
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());
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);
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());
123 m_WeightsTensor->info()->set_are_values_constant(m_WeightsTensorInfo.
IsConstant());
129 m_BiasesTensor->info()->set_are_values_constant(m_BiasesTensorInfo.
IsConstant());
133 FreeTensorIfUnused(m_WeightsTensor);
137 FreeTensorIfUnused(m_BiasesTensor);
141 m_FullyConnectedLayer->run();