Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonSpaceToDepthWorkload.hpp" |
| 7 | #include "NeonWorkloadUtils.hpp" |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 8 | |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 9 | #include <armnn/utility/NumericCast.hpp> |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 10 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Matthew Sloyan | 171214c | 2020-09-09 09:07:37 +0100 | [diff] [blame] | 11 | |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 12 | #include <ResolveType.hpp> |
| 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | |
| 17 | using namespace armcomputetensorutils; |
| 18 | |
| 19 | arm_compute::Status NeonSpaceToDepthWorkloadValidate(const TensorInfo& input, |
| 20 | const TensorInfo& output, |
| 21 | const SpaceToDepthDescriptor& 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); |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 28 | |
| 29 | return arm_compute::NESpaceToDepthLayer::validate(&aclInput, &aclOutput, blockSize); |
| 30 | } |
| 31 | |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 32 | NeonSpaceToDepthWorkload::NeonSpaceToDepthWorkload(const SpaceToDepthQueueDescriptor& descriptor, |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 33 | const WorkloadInfo& info) |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 34 | : BaseWorkload<SpaceToDepthQueueDescriptor>(descriptor, info) |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +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("NeonSpaceToDepthWorkload_Construct", |
| 38 | descriptor.m_Parameters, |
| 39 | info, |
| 40 | this->GetGuid()); |
| 41 | |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 42 | m_Data.ValidateInputsOutputs("NeonSpaceToDepthWorkload", 1, 1); |
| 43 | |
| 44 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 45 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 46 | arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 47 | input.info()->set_data_layout(aclDataLayout); |
| 48 | |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 49 | int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockSize); |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 50 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 51 | arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 52 | output.info()->set_data_layout(aclDataLayout); |
| 53 | |
| 54 | m_Layer.reset(new arm_compute::NESpaceToDepthLayer()); |
| 55 | m_Layer->configure(&input, &output, blockSize); |
| 56 | m_Layer->prepare(); |
| 57 | } |
| 58 | |
| 59 | void NeonSpaceToDepthWorkload::Execute() const |
| 60 | { |
| 61 | if (m_Layer) |
| 62 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 63 | ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonSpaceToDepthWorkload_Execute", this->GetGuid()); |
Ellen Norris-Thompson | 2979457 | 2019-06-26 16:40:36 +0100 | [diff] [blame] | 64 | m_Layer->run(); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | } //namespace armnn |