Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "RefConvertFp32ToFp16Workload.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 7 | #include "RefWorkloadUtils.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 8 | #include "Profiling.hpp" |
| 9 | |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 10 | #include <armnnUtils/FloatingPointConverter.hpp> |
| 11 | |
| 12 | #include <Half.hpp> |
arovir01 | 616e775 | 2018-10-01 17:08:59 +0100 | [diff] [blame] | 13 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 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 |