ArmNN
 21.02
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  this->m_Data.ValidateInputsOutputs("ClPadWorkload", 1, 1);
24 
25  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[0])->GetTensor();
26  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(this->m_Data.m_Outputs[0])->GetTensor();
27 
28  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_Parameters.m_PadList.size());
29 
30  std::reverse_copy(std::begin(descriptor.m_Parameters.m_PadList),
31  std::end(descriptor.m_Parameters.m_PadList),
32  std::begin(reversed_PadList));
33 
34  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
35 
36  arm_compute::PixelValue pixelValue = GetPixelValue(input, descriptor.m_Parameters.m_PadValue);
37 
38  m_Layer.configure(clCompileContext, &input, &output, padList, pixelValue);
39 }
40 
42 {
43  ARMNN_SCOPED_PROFILING_EVENT_CL("ClPadWorkload_Execute");
44  RunClFunction(m_Layer, CHECK_LOCATION());
45 }
46 
48  const TensorInfo& output,
49  const PadDescriptor& descriptor)
50 {
51  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
52  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
53 
54  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size());
55 
56  std::reverse_copy(std::begin(descriptor.m_PadList),
57  std::end(descriptor.m_PadList),
58  std::begin(reversed_PadList));
59 
60  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
61 
62  const arm_compute::Status aclStatus = arm_compute::CLPadLayer::validate(&aclInputInfo,
63  &aclOutputInfo,
64  padList);
65 
66  return aclStatus;
67 }
68 
69 } // namespace armnn
float m_PadValue
Optional value to use for padding, defaults to 0.
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
const PadQueueDescriptor m_Data
Definition: Workload.hpp:46
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.
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:26
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
std::vector< ITensorHandle * > m_Outputs
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs