blob: bec80e55f8d5e64b36e65c7b54461aa989257725 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
6#include "ClPermuteWorkload.hpp"
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00007#include <cl/ClTensorHandle.hpp>
8#include <aclCommon/ArmComputeTensorUtils.hpp>
telsoa014fcda012018-03-09 14:13:49 +00009
10#include <arm_compute/core/Error.h>
11
Matthew Bentham14e46692018-09-20 15:35:30 +010012#include "ClWorkloadUtils.hpp"
13
telsoa014fcda012018-03-09 14:13:49 +000014namespace armnn
15{
16
17arm_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 Chaimanowong157d94f2018-10-10 15:47:15 +010029ClPermuteWorkload::ClPermuteWorkload(const PermuteQueueDescriptor& descriptor,
30 const WorkloadInfo& info)
31 : BaseWorkload<PermuteQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000032{
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
telsoa01c577f2c2018-08-31 09:22:23 +010041 // Run the layer.
telsoa014fcda012018-03-09 14:13:49 +000042 m_PermuteFunction.configure(&input, &output, BuildArmComputePermutationVector(mappings));
43}
44
Nattapat Chaimanowong157d94f2018-10-10 15:47:15 +010045void ClPermuteWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000046{
telsoa01c577f2c2018-08-31 09:22:23 +010047 ARMNN_SCOPED_PROFILING_EVENT_CL( GetName() + "_Execute");
Aron Virginas-Tara8e06ed2018-10-19 16:46:15 +010048 RunClFunction(m_PermuteFunction, CHECK_LOCATION());
telsoa014fcda012018-03-09 14:13:49 +000049}
50
telsoa014fcda012018-03-09 14:13:49 +000051} // namespace armnn