2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
6 #include "RefFullyConnectedUint8Workload.hpp"
8 #include "FullyConnected.hpp"
9 #include "RefWorkloadUtils.hpp"
11 #include "Profiling.hpp"
17 RefFullyConnectedUint8Workload::RefFullyConnectedUint8Workload(
18 const FullyConnectedQueueDescriptor& descriptor, const WorkloadInfo& info)
19 : Uint8Workload<FullyConnectedQueueDescriptor>(descriptor, info),
20 m_Weight(std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Weight))),
21 m_Bias(descriptor.m_Parameters.m_BiasEnabled
22 ? std::make_unique<ScopedCpuTensorHandle>(*(descriptor.m_Bias)) : nullptr) {}
24 void RefFullyConnectedUint8Workload::Execute() const
26 ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefFullyConnectedUint8Workload_Execute");
28 const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]);
29 const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]);
31 const uint8_t* weightData = m_Weight->GetConstTensor<uint8_t>();
33 auto dequant = Dequantize(GetInputTensorDataU8(0, m_Data), inputInfo);
35 auto weight = Dequantize(weightData, m_Weight->GetTensorInfo());
37 std::vector<float> results(outputInfo.GetNumElements());
39 if (m_Data.m_Parameters.m_BiasEnabled)
41 const int32_t* biasData = m_Bias->GetConstTensor<int32_t>();
42 auto bias = Dequantize(biasData, m_Bias->GetTensorInfo());
44 FullyConnected(dequant.data(),
50 m_Data.m_Parameters.m_TransposeWeightMatrix);
54 FullyConnected(dequant.data(),
60 m_Data.m_Parameters.m_TransposeWeightMatrix);
63 Quantize(GetOutputTensorDataU8(0, m_Data), results.data(), outputInfo);