Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 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 | |
| 32 | NeonDepthToSpaceWorkload::NeonDepthToSpaceWorkload(const DepthToSpaceQueueDescriptor& desc, |
| 33 | const WorkloadInfo& info) |
| 34 | : BaseWorkload<DepthToSpaceQueueDescriptor>(desc, info) |
| 35 | { |
| 36 | m_Data.ValidateInputsOutputs("NeonDepthToSpaceWorkload", 1, 1); |
| 37 | |
| 38 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 39 | |
| 40 | arm_compute::ITensor& input = |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 41 | PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Inputs[0])->GetTensor(); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 42 | input.info()->set_data_layout(aclDataLayout); |
| 43 | |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 44 | int32_t blockSize = armnn::numeric_cast<int32_t>(desc.m_Parameters.m_BlockSize); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 45 | |
| 46 | arm_compute::ITensor& output = |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 47 | PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Outputs[0])->GetTensor(); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 48 | output.info()->set_data_layout(aclDataLayout); |
| 49 | |
| 50 | m_Layer.configure(&input, &output, blockSize); |
| 51 | m_Layer.prepare(); |
| 52 | } |
| 53 | |
| 54 | void NeonDepthToSpaceWorkload::Execute() const |
| 55 | { |
| 56 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonDepthToSpaceWorkload_Execute"); |
| 57 | m_Layer.run(); |
| 58 | } |
| 59 | |
| 60 | } // namespace armnn |