blob: cfc7c79c2da4856ebeafd9bdbdd27316832b0cf2 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
Mike Kelly7cbe7812023-07-25 17:37:33 +01002// Copyright © 2017-2023 Arm Ltd and Contributors. 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)
Teresa Charlin588cbdf2022-01-19 15:55:37 +000032 : ClBaseWorkload<PermuteQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000033{
Keith Davisbcd860a2021-08-05 14:20:33 +010034 // Report Profiling Details
35 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClPermuteWorkload_Construct",
36 descriptor.m_Parameters,
37 info,
38 this->GetGuid());
39
telsoa014fcda012018-03-09 14:13:49 +000040 using armcomputetensorutils::BuildArmComputePermutationVector;
41
42 m_Data.ValidateInputsOutputs(GetName(), 1, 1);
43
44 const arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
45 arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
46 const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings;
47
Kevin May9f6862d2021-10-22 15:42:28 +010048 {
Mike Kelly7cbe7812023-07-25 17:37:33 +010049 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClPermuteWorkload_configure");
Kevin May9f6862d2021-10-22 15:42:28 +010050 // Run the layer.
51 m_PermuteFunction.configure(clCompileContext, &input, &output, BuildArmComputePermutationVector(mappings));
52 }
telsoa014fcda012018-03-09 14:13:49 +000053}
54
Nattapat Chaimanowong157d94f2018-10-10 15:47:15 +010055void ClPermuteWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000056{
Mike Kelly7cbe7812023-07-25 17:37:33 +010057 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClPermuteWorkload_Execute");
Aron Virginas-Tara8e06ed2018-10-19 16:46:15 +010058 RunClFunction(m_PermuteFunction, CHECK_LOCATION());
telsoa014fcda012018-03-09 14:13:49 +000059}
60
telsoa014fcda012018-03-09 14:13:49 +000061} // namespace armnn