James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClSpaceToDepthWorkload.hpp" |
| 7 | #include "ClWorkloadUtils.hpp" |
| 8 | |
| 9 | #include <aclCommon/ArmComputeUtils.hpp> |
| 10 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Colm Donelan | 0c47974 | 2021-12-10 12:43:54 +0000 | [diff] [blame] | 11 | #include <armnn/backends/TensorHandle.hpp> |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 12 | #include <cl/ClTensorHandle.hpp> |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 13 | |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 14 | #include <armnn/utility/NumericCast.hpp> |
| 15 | |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 16 | namespace armnn |
| 17 | { |
| 18 | using namespace armcomputetensorutils; |
| 19 | |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 20 | ClSpaceToDepthWorkload::ClSpaceToDepthWorkload(const SpaceToDepthQueueDescriptor& descriptor, |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 21 | const WorkloadInfo& info, |
| 22 | const arm_compute::CLCompileContext& clCompileContext) |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 23 | : ClBaseWorkload<SpaceToDepthQueueDescriptor>(descriptor, info) |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 24 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 25 | // Report Profiling Details |
| 26 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClSpaceToDepthWorkload_Construct", |
| 27 | descriptor.m_Parameters, |
| 28 | info, |
| 29 | this->GetGuid()); |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 30 | m_Data.ValidateInputsOutputs("ClSpaceToDepthWorkload", 1, 1); |
| 31 | |
| 32 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 33 | |
| 34 | arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 35 | input.info()->set_data_layout(aclDataLayout); |
| 36 | |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 37 | int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockSize); |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 38 | |
| 39 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 40 | output.info()->set_data_layout(aclDataLayout); |
| 41 | |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 42 | { |
| 43 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClSpaceToDepthWorkload_configure"); |
| 44 | m_Layer.configure(clCompileContext, &input, &output, blockSize); |
| 45 | } |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void ClSpaceToDepthWorkload::Execute() const |
| 49 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 50 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClSpaceToDepthWorkload_Execute", this->GetGuid()); |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 51 | RunClFunction(m_Layer, CHECK_LOCATION()); |
| 52 | } |
| 53 | |
| 54 | arm_compute::Status ClSpaceToDepthWorkloadValidate(const TensorInfo& input, |
| 55 | const TensorInfo& output, |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 56 | const SpaceToDepthDescriptor& descriptor) |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 57 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 58 | DataLayout dataLayout = descriptor.m_DataLayout; |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 59 | const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout); |
| 60 | |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 61 | int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_BlockSize); |
James Conroy | d2aa85e | 2019-07-01 17:12:40 +0100 | [diff] [blame] | 62 | |
| 63 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, dataLayout); |
| 64 | |
| 65 | const arm_compute::Status aclStatus = arm_compute::CLSpaceToDepthLayer::validate(&aclInputInfo, |
| 66 | &aclOutputInfo, |
| 67 | blockSize); |
| 68 | return aclStatus; |
| 69 | } |
| 70 | |
| 71 | } //namespace armnn |