Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +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 | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonDepthToSpaceWorkload.hpp" |
| 7 | |
| 8 | #include "NeonWorkloadUtils.hpp" |
| 9 | |
| 10 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 11 | #include <armnn/utility/NumericCast.hpp> |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 12 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 13 | |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 14 | namespace armnn |
| 15 | { |
| 16 | |
| 17 | using namespace armcomputetensorutils; |
| 18 | |
| 19 | arm_compute::Status NeonDepthToSpaceWorkloadValidate(const TensorInfo& input, |
| 20 | const TensorInfo& output, |
| 21 | const DepthToSpaceDescriptor& descriptor) |
| 22 | { |
| 23 | DataLayout dataLayout = descriptor.m_DataLayout; |
| 24 | const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, dataLayout); |
| 25 | const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, dataLayout); |
| 26 | |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 27 | int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_BlockSize); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 28 | |
| 29 | return arm_compute::NEDepthToSpaceLayer::validate(&aclInput, &aclOutput, blockSize); |
| 30 | } |
| 31 | |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 32 | NeonDepthToSpaceWorkload::NeonDepthToSpaceWorkload(const DepthToSpaceQueueDescriptor& descriptor, |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 33 | const WorkloadInfo& info) |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 34 | : NeonBaseWorkload<DepthToSpaceQueueDescriptor>(descriptor, info) |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 35 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 36 | // Report Profiling Details |
| 37 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonDepthToSpaceWorkload_Construct", |
| 38 | descriptor.m_Parameters, |
| 39 | info, |
| 40 | this->GetGuid()); |
| 41 | |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 42 | m_Data.ValidateInputsOutputs("NeonDepthToSpaceWorkload", 1, 1); |
| 43 | |
| 44 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 45 | |
| 46 | arm_compute::ITensor& input = |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 47 | PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Inputs[0])->GetTensor(); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 48 | input.info()->set_data_layout(aclDataLayout); |
| 49 | |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 50 | int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockSize); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 51 | |
| 52 | arm_compute::ITensor& output = |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 53 | PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Outputs[0])->GetTensor(); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 54 | output.info()->set_data_layout(aclDataLayout); |
| 55 | |
| 56 | m_Layer.configure(&input, &output, blockSize); |
| 57 | m_Layer.prepare(); |
| 58 | } |
| 59 | |
| 60 | void NeonDepthToSpaceWorkload::Execute() const |
| 61 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 62 | ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonDepthToSpaceWorkload_Execute", this->GetGuid()); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 63 | m_Layer.run(); |
| 64 | } |
| 65 | |
| 66 | } // namespace armnn |