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