ArmNN
 24.02
NeonPadWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019,2021-2023 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 
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_NAME_GUID("NeonPadWorkload_Execute");
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
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:446
armnn::TensorInfo
Definition: Tensor.hpp:152
NeonTensorHandle.hpp
NeonPadWorkload.hpp
armnn::NeonPadWorkloadValidate
arm_compute::Status NeonPadWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const PadDescriptor &descriptor)
Definition: NeonPadWorkload.cpp:59
armnn::IAclTensorHandle
Definition: ArmComputeTensorHandle.hpp:16
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::PadDescriptor
A PadDescriptor for the PadLayer.
Definition: Descriptors.hpp:1196
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::PadDescriptor::m_PadValue
float m_PadValue
Optional value to use for padding, defaults to 0.
Definition: Descriptors.hpp:1221
ArmComputeUtils.hpp
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::Status
Status
Definition: Types.hpp:42
armnn::NeonPadWorkload::NeonPadWorkload
NeonPadWorkload(const PadQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: NeonPadWorkload.cpp:20
armnn::BaseWorkload< PadQueueDescriptor >::m_Data
PadQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::PadQueueDescriptor
Definition: WorkloadData.hpp:294
armnn::PadDescriptor::m_PadList
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
Definition: Descriptors.hpp:1218
armnn::ConvertPaddingModeToAcl
arm_compute::PaddingMode ConvertPaddingModeToAcl(const PaddingMode &paddingMode)
Definition: ArmComputeUtils.hpp:322
NeonWorkloadUtils.hpp
armnn::NeonPadWorkload::Execute
void Execute() const override
Definition: NeonPadWorkload.cpp:53
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
ArmComputeTensorUtils.hpp
armnn::PadDescriptor::m_PaddingMode
PaddingMode m_PaddingMode
Specifies the Padding mode (Constant, Reflect or Symmetric)
Definition: Descriptors.hpp:1224
ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: NeonWorkloadUtils.hpp:32
armnn::NeonBaseWorkload
Definition: NeonBaseWorkload.hpp:13
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26