ArmNN
 20.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  : BaseWorkload<PadQueueDescriptor>(descriptor, info)
20 {
21  this->m_Data.ValidateInputsOutputs("ClPadWorkload", 1, 1);
22 
23  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(this->m_Data.m_Inputs[0])->GetTensor();
24  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(this->m_Data.m_Outputs[0])->GetTensor();
25 
26  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_Parameters.m_PadList.size());
27 
28  std::reverse_copy(std::begin(descriptor.m_Parameters.m_PadList),
29  std::end(descriptor.m_Parameters.m_PadList),
30  std::begin(reversed_PadList));
31 
32  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
33 
34  arm_compute::PixelValue pixelValue = GetPixelValue(input, descriptor.m_Parameters.m_PadValue);
35 
36  m_Layer.configure(&input, &output, padList, pixelValue);
37 }
38 
40 {
41  ARMNN_SCOPED_PROFILING_EVENT_CL("ClPadWorkload_Execute");
42  RunClFunction(m_Layer, CHECK_LOCATION());
43 }
44 
46  const TensorInfo& output,
47  const PadDescriptor& descriptor)
48 {
49  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
50  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
51 
52  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size());
53 
54  std::reverse_copy(std::begin(descriptor.m_PadList),
55  std::end(descriptor.m_PadList),
56  std::begin(reversed_PadList));
57 
58  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
59 
60  const arm_compute::Status aclStatus = arm_compute::CLPadLayer::validate(&aclInputInfo,
61  &aclOutputInfo,
62  padList);
63 
64  return aclStatus;
65 }
66 
67 } // 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)
ClPadWorkload(const PadQueueDescriptor &descriptor, const WorkloadInfo &info)
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.
Copyright (c) 2020 ARM Limited.
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