ArmNN
 21.11
ClConvertFp16ToFp32Workload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include <cl/ClTensorHandle.hpp>
8 
9 #include "ClWorkloadUtils.hpp"
10 
11 namespace armnn
12 {
13 using namespace armcomputetensorutils;
14 
15 static constexpr arm_compute::ConvertPolicy g_AclConvertPolicy = arm_compute::ConvertPolicy::SATURATE;
16 
18  const ConvertFp16ToFp32QueueDescriptor& descriptor,
19  const WorkloadInfo& info,
20  const arm_compute::CLCompileContext& clCompileContext) :
22 {
23  this->m_Data.ValidateInputsOutputs("ClConvertFp16ToFp32Workload", 1, 1);
24 
25  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[0])->GetTensor();
26  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(this->m_Data.m_Outputs[0])->GetTensor();
27 
28  {
29  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClConvertFp16ToFp32Workload_configure");
30  m_Layer.configure(clCompileContext, &input, &output, g_AclConvertPolicy, 0);
31  }
32 }
33 
35 {
36  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClConvertFp16ToFp32Workload_Execute", this->GetGuid());
37  RunClFunction(m_Layer, CHECK_LOCATION());
38 }
39 
41 {
42  if (input.GetDataType() != DataType::Float16)
43  {
44  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Input should be Float16");
45  }
46  if (output.GetDataType() != DataType::Float32)
47  {
48  return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR, "Output should be Float32");
49  }
50 
51  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
52  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
53 
54  const arm_compute::Status aclStatus = arm_compute::CLDepthConvertLayer::validate(
55  &aclInputInfo, &aclOutputInfo, g_AclConvertPolicy, 0);
56 
57  return aclStatus;
58 }
59 
60 
61 } //namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
QueueDescriptor m_Data
Definition: Workload.hpp:58
DataType GetDataType() const
Definition: Tensor.hpp:198
arm_compute::Status ClConvertFp16ToFp32WorkloadValidate(const TensorInfo &input, const TensorInfo &output)
Status
enumeration
Definition: Types.hpp:29
ClConvertFp16ToFp32Workload(const ConvertFp16ToFp32QueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
std::vector< ITensorHandle * > m_Outputs
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs