blob: 8f3ccdbe99502a1f0a34aef15097fda4c2d687c4 [file] [log] [blame]
Mike Kellyc9ea45a2020-02-28 18:11:58 +00001//
Mike Kelly7cbe7812023-07-25 17:37:33 +01002// Copyright © 2020-2023 Arm Ltd and Contributors. All rights reserved.
Mike Kellyc9ea45a2020-02-28 18:11:58 +00003// SPDX-License-Identifier: MIT
4//
5
6#include "ClTransposeWorkload.hpp"
7#include <cl/ClTensorHandle.hpp>
8#include <aclCommon/ArmComputeTensorUtils.hpp>
9
10#include <arm_compute/core/Error.h>
11
12#include "ClWorkloadUtils.hpp"
13
14namespace armnn
15{
16
17arm_compute::Status ClTransposeWorkloadValidate(const TensorInfo& input,
18 const TensorInfo& output,
19 const TransposeDescriptor& descriptor)
20{
21 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;
24
25 return arm_compute::CLPermute::validate(&aclInputInfo, &aclOutputInfo,
26 armcomputetensorutils::BuildArmComputeTransposeVector(mappings));
27}
28
29ClTransposeWorkload::ClTransposeWorkload(const TransposeQueueDescriptor& 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<TransposeQueueDescriptor>(descriptor, info)
Mike Kellyc9ea45a2020-02-28 18:11:58 +000033{
Keith Davisbcd860a2021-08-05 14:20:33 +010034 // Report Profiling Details
35 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClTransposeWorkload_Construct",
36 descriptor.m_Parameters,
37 info,
38 this->GetGuid());
39
Mike Kellyc9ea45a2020-02-28 18:11:58 +000040 m_Data.ValidateInputsOutputs(GetName(), 1, 1);
41
42 const arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
43 arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
44 const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings;
Kevin May9f6862d2021-10-22 15:42:28 +010045 {
Mike Kelly7cbe7812023-07-25 17:37:33 +010046 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClTransposeWorkload_configure");
Kevin May9f6862d2021-10-22 15:42:28 +010047 // Run the layer.
48 m_PermuteFunction.configure(clCompileContext,
49 &input,
50 &output,
51 armcomputetensorutils::BuildArmComputeTransposeVector(mappings));
52 }
Mike Kellyc9ea45a2020-02-28 18:11:58 +000053}
54
55void ClTransposeWorkload::Execute() const
56{
Mike Kelly7cbe7812023-07-25 17:37:33 +010057 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClTransposeWorkload_Execute");
Mike Kellyc9ea45a2020-02-28 18:11:58 +000058 RunClFunction(m_PermuteFunction, CHECK_LOCATION());
59}
60
61} // namespace armnn