telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "ClPooling2dBaseWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 7 | #include <backends/cl/ClLayerSupport.hpp> |
| 8 | #include <backends/cl/ClTensorHandle.hpp> |
David Beck | 711fa31 | 2018-09-24 10:46:38 +0100 | [diff] [blame] | 9 | #include <backends/aclCommon/ArmComputeUtils.hpp> |
| 10 | #include <backends/aclCommon/ArmComputeTensorUtils.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | using namespace armcomputetensorutils; |
| 15 | |
| 16 | arm_compute::Status ClPooling2dWorkloadValidate(const TensorInfo& input, |
| 17 | const TensorInfo& output, |
| 18 | const Pooling2dDescriptor& descriptor) |
| 19 | { |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 20 | const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout); |
| 21 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 22 | |
| 23 | arm_compute::PoolingLayerInfo layerInfo = BuildArmComputePoolingLayerInfo(descriptor); |
| 24 | |
| 25 | return arm_compute::CLPoolingLayer::validate(&aclInputInfo, &aclOutputInfo, layerInfo); |
| 26 | } |
| 27 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 28 | template <armnn::DataType... dataTypes> |
| 29 | ClPooling2dBaseWorkload<dataTypes...>::ClPooling2dBaseWorkload( |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 30 | const Pooling2dQueueDescriptor& descriptor, const WorkloadInfo& info, const std::string& name) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 31 | : TypedWorkload<Pooling2dQueueDescriptor, dataTypes...>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 32 | { |
| 33 | m_Data.ValidateInputsOutputs(name, 1, 1); |
| 34 | |
| 35 | arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 36 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 37 | |
Francis Murtagh | 043d0d0 | 2018-10-05 14:08:48 +0100 | [diff] [blame] | 38 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 39 | input.info()->set_data_layout(aclDataLayout); |
| 40 | output.info()->set_data_layout(aclDataLayout); |
| 41 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | arm_compute::PoolingLayerInfo layerInfo = BuildArmComputePoolingLayerInfo(m_Data.m_Parameters); |
| 43 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 44 | // Run the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | m_PoolingLayer.configure(&input, &output, layerInfo); |
| 46 | } |
| 47 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 48 | template class ClPooling2dBaseWorkload<DataType::Float16, DataType::Float32>; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 49 | template class ClPooling2dBaseWorkload<DataType::QuantisedAsymm8>; |
| 50 | |
| 51 | } |