blob: 4cab01a0e0e02111890f7e22e6142c710dc69218 [file] [log] [blame]
Éanna Ó Catháin12055742019-01-25 10:01:40 +00001//
Mike Kelly7cbe7812023-07-25 17:37:33 +01002// Copyright © 2019,2021-2023 Arm Ltd and Contributors. All rights reserved.
Éanna Ó Catháin12055742019-01-25 10:01:40 +00003// SPDX-License-Identifier: MIT
4//
5
6#include "NeonPadWorkload.hpp"
7
8#include <neon/NeonTensorHandle.hpp>
Teresa Charlinf9de7712021-10-28 11:31:16 +01009#include <aclCommon/ArmComputeUtils.hpp>
Éanna Ó Catháin12055742019-01-25 10:01:40 +000010#include <aclCommon/ArmComputeTensorUtils.hpp>
11#include <arm_compute/core/Types.h>
12#include <arm_compute/runtime/NEON/functions/NEPadLayer.h>
13
14#include "NeonWorkloadUtils.hpp"
15
16namespace armnn
17{
18using namespace armcomputetensorutils;
19
20NeonPadWorkload::NeonPadWorkload(const PadQueueDescriptor& descriptor, const WorkloadInfo& info)
Teresa Charlin588cbdf2022-01-19 15:55:37 +000021 : NeonBaseWorkload<PadQueueDescriptor>(descriptor, info)
Éanna Ó Catháin12055742019-01-25 10:01:40 +000022{
Keith Davis2d0679f2021-08-05 11:35:00 +010023 // Report Profiling Details
24 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonPadWorkload_Construct",
25 descriptor.m_Parameters,
26 info,
27 this->GetGuid());
28
Éanna Ó Catháin12055742019-01-25 10:01:40 +000029 m_Data.ValidateInputsOutputs("NeonPadWorkload", 1, 1);
30
Derek Lambertic81855f2019-06-13 17:34:19 +010031 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();
Éanna Ó Catháin12055742019-01-25 10:01:40 +000033
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
Matthew Sloyan2e5d0b22021-10-21 14:05:31 +010042 arm_compute::PixelValue pixelValue = GetPixelValue(input.info(), descriptor.m_Parameters.m_PadValue);
FinnWilliamsArma5b5bbf2019-07-08 14:11:33 +010043
Éanna Ó Catháin12055742019-01-25 10:01:40 +000044 auto layer = std::make_unique<arm_compute::NEPadLayer>();
Teresa Charlinf9de7712021-10-28 11:31:16 +010045 layer->configure(&input,
46 &output,
47 padList,
48 pixelValue,
49 ConvertPaddingModeToAcl(descriptor.m_Parameters.m_PaddingMode));
Éanna Ó Catháin12055742019-01-25 10:01:40 +000050 m_Layer.reset(layer.release());
51}
52
53void NeonPadWorkload::Execute() const
54{
Mike Kelly7cbe7812023-07-25 17:37:33 +010055 ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonPadWorkload_Execute");
Éanna Ó Catháin12055742019-01-25 10:01:40 +000056 m_Layer->run();
57}
58
59arm_compute::Status NeonPadWorkloadValidate(const TensorInfo& input,
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);
Éanna Ó Catháin4a552012019-01-31 10:28:20 +000065
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);
Éanna Ó Catháin12055742019-01-25 10:01:40 +000073
Teresa Charlinf9de7712021-10-28 11:31:16 +010074 // 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,
80 ConvertPaddingModeToAcl(descriptor.m_PaddingMode));
Éanna Ó Catháin12055742019-01-25 10:01:40 +000081}
82
83} // namespace armnn