blob: 7ef502eb8d520dd6af8e1399e36a7ec66e3c0ec3 [file] [log] [blame]
Mike Kellyc9ea45a2020-02-28 18:11:58 +00001//
2// Copyright © 2020 Arm Ltd. All rights reserved.
3// 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)
Mike Kellyc9ea45a2020-02-28 18:11:58 +000032 : BaseWorkload<TransposeQueueDescriptor>(descriptor, info)
33{
34 m_Data.ValidateInputsOutputs(GetName(), 1, 1);
35
36 const arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
37 arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
38 const armnn::PermutationVector& mappings = m_Data.m_Parameters.m_DimMappings;
39 // Run the layer.
Sadik Armagane9444752020-12-02 11:28:58 +000040 m_PermuteFunction.configure(clCompileContext,
41 &input,
42 &output,
Mike Kellyc9ea45a2020-02-28 18:11:58 +000043 armcomputetensorutils::BuildArmComputeTransposeVector(mappings));
44}
45
46void ClTransposeWorkload::Execute() const
47{
48 ARMNN_SCOPED_PROFILING_EVENT_CL(GetName() + "_Execute");
49 RunClFunction(m_PermuteFunction, CHECK_LOCATION());
50}
51
52} // namespace armnn