Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 1 | // |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 2 | // Copyright © 2020-2023 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 "ClTransposeWorkload.hpp" |
| 7 | #include <cl/ClTensorHandle.hpp> |
| 8 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 9 | |
| 10 | #include <arm_compute/core/Error.h> |
| 11 | |
| 12 | #include "ClWorkloadUtils.hpp" |
| 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | |
| 17 | arm_compute::Status ClTransposeWorkloadValidate(const TensorInfo& input, |
| 18 | const TensorInfo& output, |
| 19 | const TransposeDescriptor& descriptor) |
| 20 | { |
| 21 | const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 22 | const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 23 | const armnn::PermutationVector& mappings = descriptor.m_DimMappings; |
| 24 | |
| 25 | return arm_compute::CLPermute::validate(&aclInputInfo, &aclOutputInfo, |
| 26 | armcomputetensorutils::BuildArmComputeTransposeVector(mappings)); |
| 27 | } |
| 28 | |
| 29 | ClTransposeWorkload::ClTransposeWorkload(const TransposeQueueDescriptor& descriptor, |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 30 | const WorkloadInfo& info, |
| 31 | const arm_compute::CLCompileContext& clCompileContext) |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 32 | : ClBaseWorkload<TransposeQueueDescriptor>(descriptor, info) |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 33 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 34 | // Report Profiling Details |
| 35 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClTransposeWorkload_Construct", |
| 36 | descriptor.m_Parameters, |
| 37 | info, |
| 38 | this->GetGuid()); |
| 39 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 40 | m_Data.ValidateInputsOutputs(GetName(), 1, 1); |
| 41 | |
| 42 | const arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 43 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 44 | const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings; |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 45 | { |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 46 | ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClTransposeWorkload_configure"); |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 47 | // Run the layer. |
| 48 | m_PermuteFunction.configure(clCompileContext, |
| 49 | &input, |
| 50 | &output, |
| 51 | armcomputetensorutils::BuildArmComputeTransposeVector(mappings)); |
| 52 | } |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void ClTransposeWorkload::Execute() const |
| 56 | { |
Mike Kelly | 7cbe781 | 2023-07-25 17:37:33 +0100 | [diff] [blame] | 57 | ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClTransposeWorkload_Execute"); |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 58 | RunClFunction(m_PermuteFunction, CHECK_LOCATION()); |
| 59 | } |
| 60 | |
| 61 | } // namespace armnn |