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 | |
| 17 | arm_compute::Status ClPermuteWorkloadValidate(const PermuteDescriptor& descriptor) |
| 18 | { |
| 19 | const armnn::PermutationVector& perm = descriptor.m_DimMappings; |
| 20 | |
| 21 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(!perm.IsEqual({ 0U, 3U, 1U, 2U }) |
| 22 | && !perm.IsEqual({ 0U, 2U, 3U, 1U }) |
| 23 | && !perm.IsEqual({ 3U, 2U, 0U, 1U }), |
| 24 | "Only [0, 3, 1, 2], [0, 2, 3, 1] and [3, 2, 0, 1] permutations are supported"); |
| 25 | |
| 26 | return arm_compute::Status{}; |
| 27 | } |
| 28 | |
Nattapat Chaimanowong | 157d94f | 2018-10-10 15:47:15 +0100 | [diff] [blame] | 29 | ClPermuteWorkload::ClPermuteWorkload(const PermuteQueueDescriptor& descriptor, |
| 30 | const WorkloadInfo& info) |
| 31 | : BaseWorkload<PermuteQueueDescriptor>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 32 | { |
| 33 | using armcomputetensorutils::BuildArmComputePermutationVector; |
| 34 | |
| 35 | m_Data.ValidateInputsOutputs(GetName(), 1, 1); |
| 36 | |
| 37 | const arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 38 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 39 | const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings; |
| 40 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 41 | // Run the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | m_PermuteFunction.configure(&input, &output, BuildArmComputePermutationVector(mappings)); |
| 43 | } |
| 44 | |
Nattapat Chaimanowong | 157d94f | 2018-10-10 15:47:15 +0100 | [diff] [blame] | 45 | void ClPermuteWorkload::Execute() const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 46 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 47 | ARMNN_SCOPED_PROFILING_EVENT_CL( GetName() + "_Execute"); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 48 | RunClFunction(m_PermuteFunction, CHECK_LOCATION()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 49 | } |
| 50 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | } // namespace armnn |