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 "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) |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 32 | : BaseWorkload<TransposeQueueDescriptor>(descriptor, info) |
| 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; |
| 45 | // Run the layer. |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 46 | m_PermuteFunction.configure(clCompileContext, |
| 47 | &input, |
| 48 | &output, |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 49 | armcomputetensorutils::BuildArmComputeTransposeVector(mappings)); |
| 50 | } |
| 51 | |
| 52 | void ClTransposeWorkload::Execute() const |
| 53 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 54 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(GetName() + "_Execute", this->GetGuid()); |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 55 | RunClFunction(m_PermuteFunction, CHECK_LOCATION()); |
| 56 | } |
| 57 | |
| 58 | } // namespace armnn |