ArmNN
 21.08
ClResizeWorkload.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 "ClResizeWorkload.hpp"
7 
8 #include "ClWorkloadUtils.hpp"
9 
12 
14 
15 #include <cl/ClTensorHandle.hpp>
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  return arm_compute::CLScale::validate(&aclInputInfo,
40  &aclOutputInfo,
41  arm_compute::ScaleKernelInfo(aclInterpolationPolicy,
42  arm_compute::BorderMode::REPLICATE,
43  arm_compute::PixelValue(0.f),
44  samplingPolicy,
45  true,
46  descriptor.m_AlignCorners));
47 }
48 
50  const WorkloadInfo& info,
51  const arm_compute::CLCompileContext& clCompileContext)
52  : BaseWorkload<ResizeQueueDescriptor>(descriptor, info)
53 {
54  // Report Profiling Details
55  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClResizeWorkload_Construct",
56  descriptor.m_Parameters,
57  info,
58  this->GetGuid());
59 
60  m_Data.ValidateInputsOutputs("ClResizeWorkload", 1, 1);
61 
62  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
63  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
64 
65  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
66  input.info()->set_data_layout(aclDataLayout);
67  output.info()->set_data_layout(aclDataLayout);
68 
69  arm_compute::InterpolationPolicy aclInterpolationPolicy =
71 
72  arm_compute::SamplingPolicy samplingPolicy = descriptor.m_Parameters.m_HalfPixelCenters
73  ? arm_compute::SamplingPolicy::CENTER
74  : arm_compute::SamplingPolicy::TOP_LEFT;
75 
76  m_ResizeLayer.configure(clCompileContext,
77  &input,
78  &output,
79  arm_compute::ScaleKernelInfo(aclInterpolationPolicy,
80  arm_compute::BorderMode::REPLICATE,
81  arm_compute::PixelValue(0.f),
82  samplingPolicy,
83  true,
84  descriptor.m_Parameters.m_AlignCorners));
85 
86 };
87 
89 {
90  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClResizeWorkload_Execute", this->GetGuid());
91  RunClFunction(m_ResizeLayer, CHECK_LOCATION());
92 }
93 
94 } //namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy(ResizeMethod resizeMethod)
DataLayout
Definition: Types.hpp:53
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
ResizeMethod m_Method
The Interpolation method to use (Bilinear, NearestNeighbor).
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
A ResizeDescriptor for the ResizeLayer.
void Execute() const override
Status
enumeration
Definition: Types.hpp:29
bool m_HalfPixelCenters
Half Pixel Centers.
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
arm_compute::Status ClResizeWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const ResizeDescriptor &descriptor)
bool m_AlignCorners
Aligned corners.
ClResizeWorkload(const ResizeQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
std::vector< ITensorHandle * > m_Outputs
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:226
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).