ArmNN
 22.02
NeonPadWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "NeonPadWorkload.hpp"
7 
11 #include <arm_compute/core/Types.h>
12 #include <arm_compute/runtime/NEON/functions/NEPadLayer.h>
13 
14 #include "NeonWorkloadUtils.hpp"
15 
16 namespace armnn
17 {
18 using namespace armcomputetensorutils;
19 
21  : NeonBaseWorkload<PadQueueDescriptor>(descriptor, info)
22 {
23  // Report Profiling Details
24  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonPadWorkload_Construct",
25  descriptor.m_Parameters,
26  info,
27  this->GetGuid());
28 
29  m_Data.ValidateInputsOutputs("NeonPadWorkload", 1, 1);
30 
31  arm_compute::ITensor& input = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
32  arm_compute::ITensor& output = static_cast<IAclTensorHandle*>(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  auto layer = std::make_unique<arm_compute::NEPadLayer>();
45  layer->configure(&input,
46  &output,
47  padList,
48  pixelValue,
50  m_Layer.reset(layer.release());
51 }
52 
54 {
55  ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonPadWorkload_Execute", this->GetGuid());
56  m_Layer->run();
57 }
58 
60  const TensorInfo& output,
61  const PadDescriptor& descriptor)
62 {
63  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
64  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
65 
66  std::vector<std::pair<unsigned int, unsigned int>> reversed_PadList(descriptor.m_PadList.size());
67 
68  std::reverse_copy(std::begin(descriptor.m_PadList),
69  std::end(descriptor.m_PadList),
70  std::begin(reversed_PadList));
71 
72  arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
73 
74  // PixelValue is currently unused when validating, but it's required to pass in PaddingMode.
75  arm_compute::PixelValue pixelValue = GetPixelValue(&aclInputInfo, descriptor.m_PadValue);
76  return arm_compute::NEPadLayer::validate(&aclInputInfo,
77  &aclOutputInfo,
78  padList,
79  pixelValue,
81 }
82 
83 } // namespace armnn
float m_PadValue
Optional value to use for padding, defaults to 0.
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) 2021 ARM Limited and Contributors.
A PadDescriptor for the PadLayer.
NeonPadWorkload(const PadQueueDescriptor &descriptor, const WorkloadInfo &info)
Status
enumeration
Definition: Types.hpp:29
arm_compute::PaddingMode ConvertPaddingModeToAcl(const PaddingMode &paddingMode)
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
PaddingMode m_PaddingMode
Specifies the Padding mode (Constant, Reflect or Symmetric)
arm_compute::Status NeonPadWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor)
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
void Execute() const override
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)