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> |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 11 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 12 | |
| 13 | #include <boost/numeric/conversion/cast.hpp> |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 14 | |
| 15 | namespace armnn |
| 16 | { |
| 17 | |
| 18 | using namespace armcomputetensorutils; |
| 19 | |
| 20 | arm_compute::Status NeonDepthToSpaceWorkloadValidate(const TensorInfo& input, |
| 21 | const TensorInfo& output, |
| 22 | const DepthToSpaceDescriptor& descriptor) |
| 23 | { |
| 24 | DataLayout dataLayout = descriptor.m_DataLayout; |
| 25 | const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, dataLayout); |
| 26 | const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, dataLayout); |
| 27 | |
| 28 | int32_t blockSize = boost::numeric_cast<int32_t>(descriptor.m_BlockSize); |
| 29 | |
| 30 | return arm_compute::NEDepthToSpaceLayer::validate(&aclInput, &aclOutput, blockSize); |
| 31 | } |
| 32 | |
| 33 | NeonDepthToSpaceWorkload::NeonDepthToSpaceWorkload(const DepthToSpaceQueueDescriptor& desc, |
| 34 | const WorkloadInfo& info) |
| 35 | : BaseWorkload<DepthToSpaceQueueDescriptor>(desc, info) |
| 36 | { |
| 37 | m_Data.ValidateInputsOutputs("NeonDepthToSpaceWorkload", 1, 1); |
| 38 | |
| 39 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 40 | |
| 41 | arm_compute::ITensor& input = |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 42 | PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Inputs[0])->GetTensor(); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 43 | input.info()->set_data_layout(aclDataLayout); |
| 44 | |
| 45 | int32_t blockSize = boost::numeric_cast<int32_t>(desc.m_Parameters.m_BlockSize); |
| 46 | |
| 47 | arm_compute::ITensor& output = |
Jan Eilers | 3c9e045 | 2020-04-10 13:00:44 +0100 | [diff] [blame] | 48 | PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Outputs[0])->GetTensor(); |
Aron Virginas-Tar | 2f00b74 | 2019-09-30 13:28:08 +0100 | [diff] [blame] | 49 | output.info()->set_data_layout(aclDataLayout); |
| 50 | |
| 51 | m_Layer.configure(&input, &output, blockSize); |
| 52 | m_Layer.prepare(); |
| 53 | } |
| 54 | |
| 55 | void NeonDepthToSpaceWorkload::Execute() const |
| 56 | { |
| 57 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonDepthToSpaceWorkload_Execute"); |
| 58 | m_Layer.run(); |
| 59 | } |
| 60 | |
| 61 | } // namespace armnn |