Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClDequantizeWorkload.hpp" |
| 7 | #include "ClWorkloadUtils.hpp" |
| 8 | |
| 9 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 10 | #include <armnn/utility/PolymorphicDowncast.hpp> |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 11 | #include <backendsCommon/TensorHandle.hpp> |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 12 | |
| 13 | #include <arm_compute/core/Types.h> |
| 14 | |
| 15 | #include <cl/ClLayerSupport.hpp> |
| 16 | #include <cl/ClTensorHandle.hpp> |
| 17 | |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 18 | namespace armnn |
| 19 | { |
| 20 | using namespace armcomputetensorutils; |
| 21 | |
| 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 | |
| 30 | ClDequantizeWorkload::ClDequantizeWorkload(const DequantizeQueueDescriptor& descriptor, |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 31 | const WorkloadInfo& workloadInfo, |
| 32 | const arm_compute::CLCompileContext& clCompileContext) |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 33 | : BaseWorkload<DequantizeQueueDescriptor>(descriptor, workloadInfo) |
| 34 | { |
Keith Davis | a856501 | 2020-02-14 12:22:40 +0000 | [diff] [blame] | 35 | m_Data.ValidateInputsOutputs("ClDequantizeWorkload", 1, 1); |
| 36 | |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 37 | arm_compute::ICLTensor& input = armnn::PolymorphicPointerDowncast<IClTensorHandle>( |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 38 | m_Data.m_Inputs[0])->GetTensor(); |
| 39 | |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 40 | arm_compute::ICLTensor& output = armnn::PolymorphicPointerDowncast<IClTensorHandle>( |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 41 | m_Data.m_Outputs[0])->GetTensor(); |
| 42 | |
| 43 | m_Layer.reset(new arm_compute::CLDequantizationLayer()); |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 44 | m_Layer->configure(clCompileContext, &input, &output); |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 45 | m_Layer->prepare(); |
| 46 | } |
| 47 | |
| 48 | void ClDequantizeWorkload::Execute() const |
| 49 | { |
| 50 | if (m_Layer) |
| 51 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 52 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClDequantizeWorkload_Execute", this->GetGuid()); |
Jim Flynn | 983daec | 2019-05-29 16:20:16 +0100 | [diff] [blame] | 53 | m_Layer->run(); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | } // namespace armnn |