ArmNN
 24.02
NeonResizeWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "NeonResizeWorkload.hpp"
7 
8 #include "NeonWorkloadUtils.hpp"
9 
14 
16 
17 using namespace armnn::armcomputetensorutils;
18 
19 namespace armnn
20 {
21 
23  const TensorInfo& output,
24  const ResizeDescriptor& descriptor)
25 {
26  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input);
27  arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
28 
29  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(descriptor.m_DataLayout);
30  aclInputInfo.set_data_layout(aclDataLayout);
31  aclOutputInfo.set_data_layout(aclDataLayout);
32 
33  arm_compute::InterpolationPolicy aclInterpolationPolicy =
35 
36  arm_compute::SamplingPolicy samplingPolicy = descriptor.m_HalfPixelCenters ? arm_compute::SamplingPolicy::CENTER :
37  arm_compute::SamplingPolicy::TOP_LEFT;
38 
39  bool usePadding = false;
40 
41  return arm_compute::NEScale::validate(&aclInputInfo,
42  &aclOutputInfo,
43  arm_compute::ScaleKernelInfo(aclInterpolationPolicy,
44  arm_compute::BorderMode::REPLICATE,
45  arm_compute::PixelValue(0.f),
46  samplingPolicy,
47  usePadding,
48  descriptor.m_AlignCorners));
49 
50 }
51 
53  const WorkloadInfo& info)
55 {
56  // Report Profiling Details
57  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonResizeWorkload_Construct",
58  descriptor.m_Parameters,
59  info,
60  this->GetGuid());
61 
62  m_Data.ValidateInputsOutputs("NeonResizeWorkload", 1, 1);
63 
64  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
65  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
66 
67  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
68  input.info()->set_data_layout(aclDataLayout);
69  output.info()->set_data_layout(aclDataLayout);
70 
71  arm_compute::InterpolationPolicy aclInterpolationPolicy =
73 
74  arm_compute::SamplingPolicy samplingPolicy = descriptor.m_Parameters.m_HalfPixelCenters
75  ? arm_compute::SamplingPolicy::CENTER
76  : arm_compute::SamplingPolicy::TOP_LEFT;
77 
78  bool usePadding = false;
79 
80  m_ResizeLayer.configure(&input,
81  &output,
82  arm_compute::ScaleKernelInfo(aclInterpolationPolicy,
83  arm_compute::BorderMode::REPLICATE,
84  arm_compute::PixelValue(0.f),
85  samplingPolicy,
86  usePadding,
87  descriptor.m_Parameters.m_AlignCorners));
88 };
89 
91 {
92  ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonResizeWorkload_Execute");
93  m_ResizeLayer.run();
94 }
95 
96 } //namespace armnn
armnn::ResizeDescriptor::m_HalfPixelCenters
bool m_HalfPixelCenters
Half Pixel Centers.
Definition: Descriptors.hpp:1018
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::ConvertResizeMethodToAclInterpolationPolicy
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy(ResizeMethod resizeMethod)
Definition: ArmComputeUtils.hpp:213
armnn::ResizeDescriptor
A ResizeDescriptor for the ResizeLayer.
Definition: Descriptors.hpp:985
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
armnn::ResizeDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:1014
armnn::NeonResizeWorkloadValidate
arm_compute::Status NeonResizeWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const ResizeDescriptor &descriptor)
Definition: NeonResizeWorkload.cpp:22
armnn::ResizeDescriptor::m_Method
ResizeMethod m_Method
The Interpolation method to use (Bilinear, NearestNeighbor).
Definition: Descriptors.hpp:1012
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
PolymorphicDowncast.hpp
ArmComputeUtils.hpp
armnn::BoostLogSeverityMapping::info
@ info
armnn::NeonResizeWorkload::Execute
void Execute() const override
Definition: NeonResizeWorkload.cpp:90
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
NeonResizeWorkload.hpp
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
TensorHandle.hpp
armnn::Status
Status
Definition: Types.hpp:42
armnn::ResizeDescriptor::m_AlignCorners
bool m_AlignCorners
Aligned corners.
Definition: Descriptors.hpp:1016
armnn::BaseWorkload< ResizeQueueDescriptor >::m_Data
ResizeQueueDescriptor m_Data
Definition: Workload.hpp:89
NeonWorkloadUtils.hpp
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::NeonResizeWorkload::NeonResizeWorkload
NeonResizeWorkload(const ResizeQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: NeonResizeWorkload.cpp:52
ArmComputeTensorUtils.hpp
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::ResizeQueueDescriptor
Definition: WorkloadData.hpp:334
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26