Release 18.08
[platform/upstream/armnn.git] / src / armnn / backends / RefWorkloads / RefConvertFp32ToFp16Workload.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
4 //
5
6 #include "RefConvertFp32ToFp16Workload.hpp"
7
8 #include "Half.hpp"
9 #include "FloatingPointConverter.hpp"
10 #include "RefWorkloadUtils.hpp"
11
12 #include "Profiling.hpp"
13
14 namespace armnn
15 {
16
17 void RefConvertFp32ToFp16Workload::Execute() const
18 {
19     ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefConvertFp32ToFp16Workload_Execute");
20
21     const float* const input = GetInputTensorDataFloat(0, m_Data);
22     Half*  const output = GetOutputTensorDataHalf(0, m_Data);
23
24     // convert Fp32 input to Fp16 output
25     unsigned int numElements = GetTensorInfo(m_Data.m_Inputs[0]).GetNumElements();
26     armnnUtils::FloatingPointConverter::ConvertFloat32To16(input, numElements, output);
27 }
28
29 } //namespace armnn