Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClDepthToSpaceWorkload.hpp" |
| 7 | |
| 8 | #include "ClWorkloadUtils.hpp" |
| 9 | |
| 10 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 11 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 12 | |
| 13 | #include <cl/ClTensorHandle.hpp> |
| 14 | |
| 15 | #include <boost/numeric/conversion/cast.hpp> |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 16 | |
| 17 | namespace armnn |
| 18 | { |
| 19 | |
| 20 | using namespace armcomputetensorutils; |
| 21 | |
| 22 | arm_compute::Status ClDepthToSpaceWorkloadValidate(const TensorInfo& input, |
| 23 | const TensorInfo& output, |
| 24 | const DepthToSpaceDescriptor& desc) |
| 25 | { |
| 26 | DataLayout dataLayout = desc.m_DataLayout; |
| 27 | const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout); |
| 28 | |
| 29 | int32_t blockSize = boost::numeric_cast<int32_t>(desc.m_BlockSize); |
| 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 | |
| 39 | ClDepthToSpaceWorkload::ClDepthToSpaceWorkload(const DepthToSpaceQueueDescriptor& desc, |
| 40 | const WorkloadInfo& info) |
| 41 | : BaseWorkload<DepthToSpaceQueueDescriptor>(desc, info) |
| 42 | { |
| 43 | m_Data.ValidateInputsOutputs("ClDepthToSpaceWorkload", 1, 1); |
| 44 | |
| 45 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 46 | |
| 47 | arm_compute::ICLTensor& input = |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 48 | PolymorphicPointerDowncast<IClTensorHandle>(m_Data.m_Inputs[0])->GetTensor(); |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 49 | input.info()->set_data_layout(aclDataLayout); |
| 50 | |
| 51 | int32_t blockSize = boost::numeric_cast<int32_t>(desc.m_Parameters.m_BlockSize); |
| 52 | |
| 53 | arm_compute::ICLTensor& output = |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 54 | PolymorphicPointerDowncast<IClTensorHandle>(m_Data.m_Outputs[0])->GetTensor(); |
Aron Virginas-Tar | b280196 | 2019-09-30 11:24:53 +0100 | [diff] [blame] | 55 | output.info()->set_data_layout(aclDataLayout); |
| 56 | |
| 57 | m_Layer.configure(&input, &output, blockSize); |
| 58 | } |
| 59 | |
| 60 | void ClDepthToSpaceWorkload::Execute() const |
| 61 | { |
| 62 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClDepthToSpaceWorkload_Execute"); |
| 63 | RunClFunction(m_Layer, CHECK_LOCATION()); |
| 64 | } |
| 65 | |
| 66 | } // namespace armnn |