telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "ClPermuteWorkload.hpp" |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 7 | #include <cl/ClTensorHandle.hpp> |
| 8 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | |
| 10 | #include <arm_compute/core/Error.h> |
| 11 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 12 | #include "ClWorkloadUtils.hpp" |
| 13 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | namespace armnn |
| 15 | { |
| 16 | |
Matthew Bentham | 9820d30 | 2019-11-27 17:24:47 +0000 | [diff] [blame] | 17 | arm_compute::Status ClPermuteWorkloadValidate(const TensorInfo& input, |
| 18 | const TensorInfo& output, |
| 19 | const PermuteDescriptor& descriptor) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | { |
Matthew Bentham | 9820d30 | 2019-11-27 17:24:47 +0000 | [diff] [blame] | 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; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 24 | |
Matthew Bentham | 9820d30 | 2019-11-27 17:24:47 +0000 | [diff] [blame] | 25 | return arm_compute::CLPermute::validate(&aclInputInfo, &aclOutputInfo, |
Kevin May | a023c40 | 2019-12-12 17:28:05 +0000 | [diff] [blame] | 26 | armcomputetensorutils::BuildArmComputePermutationVector(mappings)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | } |
| 28 | |
Nattapat Chaimanowong | 157d94f | 2018-10-10 15:47:15 +0100 | [diff] [blame] | 29 | ClPermuteWorkload::ClPermuteWorkload(const PermuteQueueDescriptor& 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<PermuteQueueDescriptor>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +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("ClPermuteWorkload_Construct", |
| 36 | descriptor.m_Parameters, |
| 37 | info, |
| 38 | this->GetGuid()); |
| 39 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 40 | using armcomputetensorutils::BuildArmComputePermutationVector; |
| 41 | |
| 42 | m_Data.ValidateInputsOutputs(GetName(), 1, 1); |
| 43 | |
| 44 | const arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 45 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 46 | const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings; |
| 47 | |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 48 | { |
| 49 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClPermuteWorkload_configure"); |
| 50 | // Run the layer. |
| 51 | m_PermuteFunction.configure(clCompileContext, &input, &output, BuildArmComputePermutationVector(mappings)); |
| 52 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Nattapat Chaimanowong | 157d94f | 2018-10-10 15:47:15 +0100 | [diff] [blame] | 55 | void ClPermuteWorkload::Execute() const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 56 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 57 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(GetName() + "_Execute", this->GetGuid()); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 58 | RunClFunction(m_PermuteFunction, CHECK_LOCATION()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 59 | } |
| 60 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 61 | } // namespace armnn |