Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 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) |
| 29 | : BaseWorkload<TransposeQueueDescriptor>(descriptor, info) |
| 30 | { |
| 31 | m_Data.ValidateInputsOutputs(GetName(), 1, 1); |
| 32 | |
| 33 | const arm_compute::ITensor& input = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 34 | arm_compute::ITensor& output = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 35 | const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings; |
| 36 | |
| 37 | // Run the layer. |
| 38 | m_PermuteFunction.configure(&input, &output, |
| 39 | armcomputetensorutils::BuildArmComputeTransposeVector(mappings)); |
| 40 | } |
| 41 | |
| 42 | void NeonTransposeWorkload::Execute() const |
| 43 | { |
| 44 | ARMNN_SCOPED_PROFILING_EVENT_NEON(GetName() + "_Execute"); |
| 45 | m_PermuteFunction.run(); |
| 46 | } |
| 47 | |
| 48 | } // namespace armnn |