2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include "ClPermuteWorkload.hpp"
7 #include <backends/cl/ClTensorHandle.hpp>
8 #include <backends/aclCommon/ArmComputeTensorUtils.hpp>
10 #include <arm_compute/core/Error.h>
12 #include "ClWorkloadUtils.hpp"
17 arm_compute::Status ClPermuteWorkloadValidate(const PermuteDescriptor& descriptor)
19 const armnn::PermutationVector& perm = descriptor.m_DimMappings;
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");
26 return arm_compute::Status{};
29 ClPermuteWorkload::ClPermuteWorkload(const PermuteQueueDescriptor& descriptor,
30 const WorkloadInfo& info)
31 : BaseWorkload<PermuteQueueDescriptor>(descriptor, info)
33 using armcomputetensorutils::BuildArmComputePermutationVector;
35 m_Data.ValidateInputsOutputs(GetName(), 1, 1);
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;
42 m_PermuteFunction.configure(&input, &output, BuildArmComputePermutationVector(mappings));
45 void ClPermuteWorkload::Execute() const
47 ARMNN_SCOPED_PROFILING_EVENT_CL( GetName() + "_Execute");
48 RunClFunction(m_PermuteFunction, CHECK_LOCATION());