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 "ClConvertFp16ToFp32Workload.hpp" |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 7 | #include <cl/ClTensorHandle.hpp> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 8 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 9 | #include "ClWorkloadUtils.hpp" |
| 10 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 11 | namespace armnn |
| 12 | { |
| 13 | using namespace armcomputetensorutils; |
| 14 | |
| 15 | static constexpr arm_compute::ConvertPolicy g_AclConvertPolicy = arm_compute::ConvertPolicy::SATURATE; |
| 16 | |
| 17 | ClConvertFp16ToFp32Workload::ClConvertFp16ToFp32Workload( |
| 18 | const ConvertFp16ToFp32QueueDescriptor& descriptor, const WorkloadInfo& info) : |
| 19 | Float16ToFloat32Workload<ConvertFp16ToFp32QueueDescriptor>(descriptor, info) |
| 20 | { |
| 21 | this->m_Data.ValidateInputsOutputs("ClConvertFp16ToFp32Workload", 1, 1); |
| 22 | |
| 23 | arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[0])->GetTensor(); |
| 24 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(this->m_Data.m_Outputs[0])->GetTensor(); |
| 25 | |
| 26 | m_Layer.configure(&input, &output, g_AclConvertPolicy, 0); |
| 27 | } |
| 28 | |
| 29 | void ClConvertFp16ToFp32Workload::Execute() const |
| 30 | { |
| 31 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClConvertFp16ToFp32Workload_Execute"); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 32 | RunClFunction(m_Layer, CHECK_LOCATION()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 33 | } |
| 34 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 35 | arm_compute::Status ClConvertFp16ToFp32WorkloadValidate(const TensorInfo& input, const TensorInfo& output) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 36 | { |
| 37 | if (input.GetDataType() != DataType::Float16) |
| 38 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 39 | return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Input should be Float16"); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 40 | } |
| 41 | if (output.GetDataType() != DataType::Float32) |
| 42 | { |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 43 | return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Output should be Float32"); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input); |
| 47 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output); |
| 48 | |
| 49 | const arm_compute::Status aclStatus = arm_compute::CLDepthConvertLayer::validate( |
| 50 | &aclInputInfo, &aclOutputInfo, g_AclConvertPolicy, 0); |
| 51 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 52 | return aclStatus; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | } //namespace armnn |