blob: fa811e1a32f9acbcba49c150898b6ce2781fca99 [file] [log] [blame]
telsoa01c577f2c2018-08-31 09:22:23 +01001//
Matthew Sloyan2d213a72022-06-30 17:13:04 +01002// Copyright © 2022 Arm Ltd and Contributors. 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 "RefConvertFp16ToFp32Workload.hpp"
telsoa01c577f2c2018-08-31 09:22:23 +01007#include "RefWorkloadUtils.hpp"
Matteo Martincighe011d202019-11-28 11:35:47 +00008
9#include <armnnUtils/FloatingPointConverter.hpp>
telsoa01c577f2c2018-08-31 09:22:23 +010010
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000011#include <Half.hpp>
arovir01616e7752018-10-01 17:08:59 +010012
telsoa01c577f2c2018-08-31 09:22:23 +010013namespace armnn
14{
15
16void RefConvertFp16ToFp32Workload::Execute() const
17{
Finn Williamsb8181f72021-04-07 10:23:21 +010018 Execute(m_Data.m_Inputs, m_Data.m_Outputs);
19}
20
Matthew Sloyan2d213a72022-06-30 17:13:04 +010021void RefConvertFp16ToFp32Workload::ExecuteAsync(ExecutionData& executionData)
Finn Williamsb8181f72021-04-07 10:23:21 +010022{
Matthew Sloyan2d213a72022-06-30 17:13:04 +010023 WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
24 Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
Finn Williamsb8181f72021-04-07 10:23:21 +010025}
26
27void RefConvertFp16ToFp32Workload::Execute(std::vector<ITensorHandle*> inputs,
28 std::vector<ITensorHandle*> outputs) const
29{
telsoa01c577f2c2018-08-31 09:22:23 +010030 ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefConvertFp16ToFp32Workload_Execute");
31
Finn Williamsb8181f72021-04-07 10:23:21 +010032 const Half* const input = reinterpret_cast<const Half*>(inputs[0]->Map());
33 float* const output = reinterpret_cast<float*>(outputs[0]->Map());
telsoa01c577f2c2018-08-31 09:22:23 +010034
Finn Williamsb8181f72021-04-07 10:23:21 +010035 unsigned int numElements = GetTensorInfo(inputs[0]).GetNumElements();
telsoa01c577f2c2018-08-31 09:22:23 +010036 armnnUtils::FloatingPointConverter::ConvertFloat16To32(input, numElements, output);
37}
38
39} //namespace armnn