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> |
| 10 | #include <backendsCommon/CpuTensorHandle.hpp> |
| 11 | |
| 12 | #include <arm_compute/core/Types.h> |
| 13 | |
| 14 | #include <cl/ClLayerSupport.hpp> |
| 15 | #include <cl/ClTensorHandle.hpp> |
| 16 | |
| 17 | #include <boost/polymorphic_pointer_cast.hpp> |
| 18 | |
| 19 | namespace armnn |
| 20 | { |
| 21 | using namespace armcomputetensorutils; |
| 22 | |
| 23 | arm_compute::Status ClDequantizeWorkloadValidate(const TensorInfo& input, 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::CLDequantizationLayer::validate(&aclInputInfo, &aclOutputInfo); |
| 29 | } |
| 30 | |
| 31 | ClDequantizeWorkload::ClDequantizeWorkload(const DequantizeQueueDescriptor& descriptor, |
| 32 | const WorkloadInfo& workloadInfo) |
| 33 | : BaseWorkload<DequantizeQueueDescriptor>(descriptor, workloadInfo) |
| 34 | { |
| 35 | arm_compute::ICLTensor& input = boost::polymorphic_pointer_downcast<IClTensorHandle>( |
| 36 | m_Data.m_Inputs[0])->GetTensor(); |
| 37 | |
| 38 | arm_compute::ICLTensor& output = boost::polymorphic_pointer_downcast<IClTensorHandle>( |
| 39 | m_Data.m_Outputs[0])->GetTensor(); |
| 40 | |
| 41 | m_Layer.reset(new arm_compute::CLDequantizationLayer()); |
| 42 | m_Layer->configure(&input, &output); |
| 43 | m_Layer->prepare(); |
| 44 | } |
| 45 | |
| 46 | void ClDequantizeWorkload::Execute() const |
| 47 | { |
| 48 | if (m_Layer) |
| 49 | { |
| 50 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClDequantizeWorkload_Execute"); |
| 51 | m_Layer->run(); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | } // namespace armnn |