Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonTransposeWorkload.hpp" |
| 7 | #include <neon/NeonTensorHandle.hpp> |
| 8 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 9 | |
| 10 | #include <arm_compute/core/Error.h> |
| 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | |
| 15 | arm_compute::Status NeonTransposeWorkloadValidate(const TensorInfo& input, |
| 16 | const TensorInfo& output, |
| 17 | const TransposeDescriptor& descriptor) |
| 18 | { |
| 19 | const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 20 | const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 21 | const armnn::PermutationVector& mappings = descriptor.m_DimMappings; |
| 22 | |
| 23 | return arm_compute::NEPermute::validate(&aclInputInfo, &aclOutputInfo, |
| 24 | armcomputetensorutils::BuildArmComputeTransposeVector(mappings)); |
| 25 | } |
| 26 | |
| 27 | NeonTransposeWorkload::NeonTransposeWorkload(const TransposeQueueDescriptor& descriptor, |
| 28 | const WorkloadInfo& info) |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 29 | : NeonBaseWorkload<TransposeQueueDescriptor>(descriptor, info) |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 30 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 31 | // Report Profiling Details |
| 32 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonTransposeWorkload_Construct", |
| 33 | descriptor.m_Parameters, |
| 34 | info, |
| 35 | this->GetGuid()); |
| 36 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 37 | m_Data.ValidateInputsOutputs(GetName(), 1, 1); |
| 38 | |
| 39 | const arm_compute::ITensor& input = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 40 | arm_compute::ITensor& output = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 41 | const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings; |
| 42 | |
| 43 | // Run the layer. |
| 44 | m_PermuteFunction.configure(&input, &output, |
| 45 | armcomputetensorutils::BuildArmComputeTransposeVector(mappings)); |
| 46 | } |
| 47 | |
| 48 | void NeonTransposeWorkload::Execute() const |
| 49 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 50 | ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(GetName() + "_Execute", this->GetGuid()); |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 51 | m_PermuteFunction.run(); |
| 52 | } |
| 53 | |
| 54 | } // namespace armnn |