jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClPadWorkload.hpp" |
| 7 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 8 | #include <cl/ClTensorHandle.hpp> |
| 9 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 10 | #include <arm_compute/core/Types.h> |
| 11 | |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 12 | #include "ClWorkloadUtils.hpp" |
| 13 | |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 14 | namespace armnn |
| 15 | { |
| 16 | using namespace armcomputetensorutils; |
| 17 | |
Nattapat Chaimanowong | 4e00a3d | 2018-10-09 17:05:24 +0100 | [diff] [blame] | 18 | ClPadWorkload::ClPadWorkload(const PadQueueDescriptor& descriptor, const WorkloadInfo& info) |
| 19 | : BaseWorkload<PadQueueDescriptor>(descriptor, info) |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 20 | { |
| 21 | this->m_Data.ValidateInputsOutputs("ClPadWorkload", 1, 1); |
| 22 | |
| 23 | arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[0])->GetTensor(); |
| 24 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(this->m_Data.m_Outputs[0])->GetTensor(); |
Mohamed Nour Abouelseoud | 7420e55 | 2018-10-12 12:26:24 +0100 | [diff] [blame] | 25 | |
| 26 | std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_Parameters.m_PadList.size()); |
| 27 | |
| 28 | std::reverse_copy(std::begin(descriptor.m_Parameters.m_PadList), |
| 29 | std::end(descriptor.m_Parameters.m_PadList), |
| 30 | std::begin(reversed_PadList)); |
| 31 | |
| 32 | arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList); |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 33 | |
| 34 | m_Layer.configure(&input, &output, padList); |
| 35 | } |
| 36 | |
Nattapat Chaimanowong | 4e00a3d | 2018-10-09 17:05:24 +0100 | [diff] [blame] | 37 | void ClPadWorkload::Execute() const |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 38 | { |
| 39 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClPadWorkload_Execute"); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 40 | RunClFunction(m_Layer, CHECK_LOCATION()); |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 41 | } |
| 42 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 43 | arm_compute::Status ClPadValidate(const TensorInfo& input, |
| 44 | const TensorInfo& output, |
| 45 | const PadDescriptor& descriptor) |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 46 | { |
| 47 | const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input); |
| 48 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output); |
Éanna Ó Catháin | d0a1608 | 2019-01-14 15:50:08 +0000 | [diff] [blame] | 49 | |
| 50 | std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size()); |
| 51 | |
| 52 | std::reverse_copy(std::begin(descriptor.m_PadList), |
| 53 | std::end(descriptor.m_PadList), |
| 54 | std::begin(reversed_PadList)); |
| 55 | |
| 56 | arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList); |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 57 | |
| 58 | const arm_compute::Status aclStatus = arm_compute::CLPadLayer::validate(&aclInputInfo, |
| 59 | &aclOutputInfo, |
| 60 | padList); |
| 61 | |
arovir01 | 085f0a4 | 2018-10-08 14:48:19 +0100 | [diff] [blame] | 62 | return aclStatus; |
jimfly01 | e1fa50c | 2018-09-21 12:09:51 +0100 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | } // namespace armnn |