blob: 5aadc7629e587ac7d395506b9343e615d4aca122 [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
Matthew Bentham9820d302019-11-27 17:24:47 +000017arm_compute::Status ClPermuteWorkloadValidate(const TensorInfo& input,
18 const TensorInfo& output,
19 const PermuteDescriptor& descriptor)
telsoa014fcda012018-03-09 14:13:49 +000020{
Matthew Bentham9820d302019-11-27 17:24:47 +000021 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;
telsoa014fcda012018-03-09 14:13:49 +000024
Matthew Bentham9820d302019-11-27 17:24:47 +000025 return arm_compute::CLPermute::validate(&aclInputInfo, &aclOutputInfo,
Kevin Maya023c402019-12-12 17:28:05 +000026 armcomputetensorutils::BuildArmComputePermutationVector(mappings));
telsoa014fcda012018-03-09 14:13:49 +000027}
28
Nattapat Chaimanowong157d94f2018-10-10 15:47:15 +010029ClPermuteWorkload::ClPermuteWorkload(const PermuteQueueDescriptor& descriptor,
Sadik Armagane9444752020-12-02 11:28:58 +000030 const WorkloadInfo& info,
31 const arm_compute::CLCompileContext& clCompileContext)
Nattapat Chaimanowong157d94f2018-10-10 15:47:15 +010032 : BaseWorkload<PermuteQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000033{
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
telsoa01c577f2c2018-08-31 09:22:23 +010042 // Run the layer.
Sadik Armagane9444752020-12-02 11:28:58 +000043 m_PermuteFunction.configure(clCompileContext, &input, &output, BuildArmComputePermutationVector(mappings));
telsoa014fcda012018-03-09 14:13:49 +000044}
45
Nattapat Chaimanowong157d94f2018-10-10 15:47:15 +010046void ClPermuteWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000047{
telsoa01c577f2c2018-08-31 09:22:23 +010048 ARMNN_SCOPED_PROFILING_EVENT_CL( GetName() + "_Execute");
Aron Virginas-Tara8e06ed2018-10-19 16:46:15 +010049 RunClFunction(m_PermuteFunction, CHECK_LOCATION());
telsoa014fcda012018-03-09 14:13:49 +000050}
51
telsoa014fcda012018-03-09 14:13:49 +000052} // namespace armnn