telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 2 | // Copyright © 2022 Arm Ltd and Contributors. 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 "RefConvertFp16ToFp32Workload.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 7 | #include "RefWorkloadUtils.hpp" |
Matteo Martincigh | e011d20 | 2019-11-28 11:35:47 +0000 | [diff] [blame] | 8 | |
| 9 | #include <armnnUtils/FloatingPointConverter.hpp> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 10 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 11 | #include <Half.hpp> |
arovir01 | 616e775 | 2018-10-01 17:08:59 +0100 | [diff] [blame] | 12 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | void RefConvertFp16ToFp32Workload::Execute() const |
| 17 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 18 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 19 | } |
| 20 | |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 21 | void RefConvertFp16ToFp32Workload::ExecuteAsync(ExecutionData& executionData) |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 22 | { |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 23 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 24 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | void RefConvertFp16ToFp32Workload::Execute(std::vector<ITensorHandle*> inputs, |
| 28 | std::vector<ITensorHandle*> outputs) const |
| 29 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 30 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefConvertFp16ToFp32Workload_Execute"); |
| 31 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 32 | const Half* const input = reinterpret_cast<const Half*>(inputs[0]->Map()); |
| 33 | float* const output = reinterpret_cast<float*>(outputs[0]->Map()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 34 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 35 | unsigned int numElements = GetTensorInfo(inputs[0]).GetNumElements(); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 36 | armnnUtils::FloatingPointConverter::ConvertFloat16To32(input, numElements, output); |
| 37 | } |
| 38 | |
| 39 | } //namespace armnn |