telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
| 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 "NeonConvertFp16ToFp32Workload.hpp" |
| 7 | #include "Half.hpp" |
| 8 | #include "FloatingPointConverter.hpp" |
| 9 | |
| 10 | #include "backends/WorkloadUtils.hpp" |
| 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | |
| 15 | NeonConvertFp16ToFp32Workload::NeonConvertFp16ToFp32Workload(const ConvertFp16ToFp32QueueDescriptor& descriptor, |
| 16 | const WorkloadInfo& info) |
| 17 | : Float16ToFloat32Workload<ConvertFp16ToFp32QueueDescriptor>(descriptor, info) |
| 18 | { |
| 19 | this->m_Data.ValidateInputsOutputs("NeonConvertFp16ToFp32Workload", 1, 1); |
| 20 | GatherTensorHandlePairs(descriptor, m_TensorHandlePairs); |
| 21 | } |
| 22 | |
| 23 | void NeonConvertFp16ToFp32Workload::Execute() const |
| 24 | { |
| 25 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonConvertFp16ToFp32Workload_Execute"); |
| 26 | |
| 27 | auto convertFunc = [](uint8_t* dst, const uint8_t* src, size_t size) |
| 28 | { |
| 29 | auto input = reinterpret_cast<const Half*>(src); |
| 30 | auto output = reinterpret_cast<float*>(dst); |
| 31 | size_t numElements = size/2; // 2 bytes per fp16 |
| 32 | armnnUtils::FloatingPointConverter::ConvertFloat16To32(input, numElements, output); |
| 33 | }; |
| 34 | |
| 35 | for (const auto& pair : m_TensorHandlePairs) |
| 36 | { |
| 37 | CopyTensorContentsGeneric(pair.first, pair.second, convertFunc); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | } //namespace armnn |