blob: c68960fad2e6034f692671134d1071e731fe3417 [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
telsoa01c577f2c2018-08-31 09:22:23 +01002// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa01c577f2c2018-08-31 09:22:23 +01004//
5
6#include "RefConvertFp32ToFp16Workload.hpp"
telsoa01c577f2c2018-08-31 09:22:23 +01007#include "RefWorkloadUtils.hpp"
telsoa01c577f2c2018-08-31 09:22:23 +01008#include "Profiling.hpp"
9
Matteo Martincighe011d202019-11-28 11:35:47 +000010#include <armnnUtils/FloatingPointConverter.hpp>
11
12#include <Half.hpp>
arovir01616e7752018-10-01 17:08:59 +010013
telsoa01c577f2c2018-08-31 09:22:23 +010014namespace armnn
15{
16
17void 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