ArmNN
 21.08
ClTransposeWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include <cl/ClTensorHandle.hpp>
9 
10 #include <arm_compute/core/Error.h>
11 
12 #include "ClWorkloadUtils.hpp"
13 
14 namespace armnn
15 {
16 
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 
30  const WorkloadInfo& info,
31  const arm_compute::CLCompileContext& clCompileContext)
32  : BaseWorkload<TransposeQueueDescriptor>(descriptor, info)
33 {
34  // Report Profiling Details
35  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClTransposeWorkload_Construct",
36  descriptor.m_Parameters,
37  info,
38  this->GetGuid());
39 
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();
45  // Run the layer.
46  m_PermuteFunction.configure(clCompileContext,
47  &input,
48  &output,
49  armcomputetensorutils::BuildArmComputeTransposeVector(mappings));
50 }
51 
53 {
54  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(GetName() + "_Execute", this->GetGuid());
55  RunClFunction(m_PermuteFunction, CHECK_LOCATION());
56 }
57 
58 } // namespace armnn
void Execute() const override
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
static const std::string & GetName()
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
arm_compute::Status ClTransposeWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const TransposeDescriptor &descriptor)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
ClTransposeWorkload(const TransposeQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Status
enumeration
Definition: Types.hpp:29
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
std::vector< ITensorHandle * > m_Outputs
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:226
A TransposeDescriptor for the TransposeLayer.
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
PermutationVector m_DimMappings
Indicates how to translate tensor elements from a given source into the target destination, when source and target potentially have different memory layouts e.g.