ArmNN
 21.11
ClPadWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ClPadWorkload.hpp"
7 
8 #include <cl/ClTensorHandle.hpp>
10 #include <arm_compute/core/Types.h>
11 
12 #include "ClWorkloadUtils.hpp"
13 
14 namespace armnn
15 {
16 using namespace armcomputetensorutils;
17 
19  const WorkloadInfo& info,
20  const arm_compute::CLCompileContext& clCompileContext)
21  : BaseWorkload<PadQueueDescriptor>(descriptor, info)
22 {
23  // Report Profiling Details
24  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClPadWorkload_Construct",
25  descriptor.m_Parameters,
26  info,
27  this->GetGuid());
28 
29  this->m_Data.ValidateInputsOutputs("ClPadWorkload", 1, 1);
30 
31  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[0])->GetTensor();
32  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(this->m_Data.m_Outputs[0])->GetTensor();
33 
34  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_Parameters.m_PadList.size());
35 
36  std::reverse_copy(std::begin(descriptor.m_Parameters.m_PadList),
37  std::end(descriptor.m_Parameters.m_PadList),
38  std::begin(reversed_PadList));
39 
40  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
41 
42  arm_compute::PixelValue pixelValue = GetPixelValue(input.info(), descriptor.m_Parameters.m_PadValue);
43 
44  {
45  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClPadWorkload_configure");
46  m_Layer.configure(clCompileContext, &input, &output, padList, pixelValue);
47  }
48 }
49 
51 {
52  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClPadWorkload_Execute", this->GetGuid());
53  RunClFunction(m_Layer, CHECK_LOCATION());
54 }
55 
57  const TensorInfo& output,
58  const PadDescriptor& descriptor)
59 {
60  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
61  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
62 
63  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size());
64 
65  std::reverse_copy(std::begin(descriptor.m_PadList),
66  std::end(descriptor.m_PadList),
67  std::begin(reversed_PadList));
68 
69  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
70 
71  const arm_compute::Status aclStatus = arm_compute::CLPadLayer::validate(&aclInputInfo,
72  &aclOutputInfo,
73  padList);
74 
75  return aclStatus;
76 }
77 
78 } // namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
float m_PadValue
Optional value to use for padding, defaults to 0.
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
ClPadWorkload(const PadQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Copyright (c) 2021 ARM Limited and Contributors.
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
A PadDescriptor for the PadLayer.
void Execute() const override
arm_compute::Status ClPadValidate(const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor)
Status
enumeration
Definition: Types.hpp:29
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209
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:227
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs