1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "ClQuantizeWorkload.hpp"
7 #include "ClWorkloadUtils.hpp"
8
9 #include <aclCommon/ArmComputeUtils.hpp>
10 #include <aclCommon/ArmComputeTensorUtils.hpp>
11
12 #include <armnn/backends/TensorHandle.hpp>
13
14 #include <cl/ClLayerSupport.hpp>
15 #include <cl/ClTensorHandle.hpp>
16 #include <cl/ClLayerSupport.hpp>
17
18 namespace armnn
19 {
20 using namespace armcomputetensorutils;
21
ClQuantizeWorkloadValidate(const TensorInfo & input,const TensorInfo & output)22 arm_compute::Status ClQuantizeWorkloadValidate(const TensorInfo& input,
23 const TensorInfo& output)
24 {
25 const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
26 const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
27
28 return arm_compute::CLQuantizationLayer::validate(&aclInputInfo,
29 &aclOutputInfo);
30 }
31
ClQuantizeWorkload(const QuantizeQueueDescriptor & descriptor,const WorkloadInfo & info,const arm_compute::CLCompileContext & clCompileContext)32 ClQuantizeWorkload::ClQuantizeWorkload(const QuantizeQueueDescriptor& descriptor,
33 const WorkloadInfo& info,
34 const arm_compute::CLCompileContext& clCompileContext)
35 : ClBaseWorkload<QuantizeQueueDescriptor>(descriptor, info)
36 {
37 m_Data.ValidateInputsOutputs("ClQuantizeWorkload", 1, 1);
38
39 arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
40 arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
41
42 {
43 ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClQuantizeWorkload_configure");
44 m_Layer.configure(clCompileContext, &input, &output);
45 }
46 }
47
Execute() const48 void ClQuantizeWorkload::Execute() const
49 {
50 ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClQuantizeWorkload_Execute", this->GetGuid());
51 RunClFunction(m_Layer, CHECK_LOCATION());
52 }
53
54 } //namespace armnn
55