telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. 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) |
Nattapat Chaimanowong | 157d94f | 2018-10-10 15:47:15 +0100 | [diff] [blame] | 32 | : BaseWorkload<PermuteQueueDescriptor>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 33 | { |
| 34 | using armcomputetensorutils::BuildArmComputePermutationVector; |
| 35 | |
| 36 | m_Data.ValidateInputsOutputs(GetName(), 1, 1); |
| 37 | |
| 38 | const arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 39 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 40 | const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings; |
| 41 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 42 | // Run the layer. |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 43 | m_PermuteFunction.configure(clCompileContext, &input, &output, BuildArmComputePermutationVector(mappings)); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Nattapat Chaimanowong | 157d94f | 2018-10-10 15:47:15 +0100 | [diff] [blame] | 46 | void ClPermuteWorkload::Execute() const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 47 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 48 | ARMNN_SCOPED_PROFILING_EVENT_CL( GetName() + "_Execute"); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 49 | RunClFunction(m_PermuteFunction, CHECK_LOCATION()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 50 | } |
| 51 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 52 | } // namespace armnn |