1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "ClDequantizeWorkload.hpp"
7 #include "ClWorkloadUtils.hpp"
8
9 #include <aclCommon/ArmComputeTensorUtils.hpp>
10 #include <armnn/utility/PolymorphicDowncast.hpp>
11 #include <armnn/backends/TensorHandle.hpp>
12
13 #include <arm_compute/core/Types.h>
14
15 #include <cl/ClLayerSupport.hpp>
16 #include <cl/ClTensorHandle.hpp>
17
18 namespace armnn
19 {
20 using namespace armcomputetensorutils;
21
ClDequantizeWorkloadValidate(const TensorInfo & input,const TensorInfo & output)22 arm_compute::Status ClDequantizeWorkloadValidate(const TensorInfo& input, const TensorInfo& output)
23 {
24 const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
25 const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
26
27 return arm_compute::CLDequantizationLayer::validate(&aclInputInfo, &aclOutputInfo);
28 }
29
ClDequantizeWorkload(const DequantizeQueueDescriptor & descriptor,const WorkloadInfo & workloadInfo,const arm_compute::CLCompileContext & clCompileContext)30 ClDequantizeWorkload::ClDequantizeWorkload(const DequantizeQueueDescriptor& descriptor,
31 const WorkloadInfo& workloadInfo,
32 const arm_compute::CLCompileContext& clCompileContext)
33 : ClBaseWorkload<DequantizeQueueDescriptor>(descriptor, workloadInfo)
34 {
35 m_Data.ValidateInputsOutputs("ClDequantizeWorkload", 1, 1);
36
37 arm_compute::ICLTensor& input = armnn::PolymorphicPointerDowncast<IClTensorHandle>(
38 m_Data.m_Inputs[0])->GetTensor();
39
40 arm_compute::ICLTensor& output = armnn::PolymorphicPointerDowncast<IClTensorHandle>(
41 m_Data.m_Outputs[0])->GetTensor();
42
43 m_Layer.reset(new arm_compute::CLDequantizationLayer());
44 {
45 ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClDequantizeWorkload_configure");
46 m_Layer->configure(clCompileContext, &input, &output);
47 }
48 m_Layer->prepare();
49 }
50
Execute() const51 void ClDequantizeWorkload::Execute() const
52 {
53 if (m_Layer)
54 {
55 ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClDequantizeWorkload_Execute", this->GetGuid());
56 m_Layer->run();
57 }
58 }
59
60 } // namespace armnn
61