ArmNN
 21.08
ClL2NormalizationFloatWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include <cl/ClTensorHandle.hpp>
10 
11 #include "ClWorkloadUtils.hpp"
12 
13 namespace armnn
14 {
15 using namespace armcomputetensorutils;
16 
18  const TensorInfo& output,
19  const L2NormalizationDescriptor& descriptor)
20 {
21  const arm_compute::TensorInfo aclInput = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
22  const arm_compute::TensorInfo aclOutput = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
23 
24  int axis = (descriptor.m_DataLayout == DataLayout::NCHW) ? 2 : 0;
25 
26  return arm_compute::CLL2NormalizeLayer::validate(&aclInput, &aclOutput, axis, descriptor.m_Eps);
27 }
28 
30  const WorkloadInfo& info,
31  const arm_compute::CLCompileContext& clCompileContext)
33 {
34  // Report Profiling Details
35  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClL2NormalizationFloatWorkload_Construct",
36  descriptor.m_Parameters,
37  info,
38  this->GetGuid());
39 
40  m_Data.ValidateInputsOutputs("ClL2NormalizationFloatWorkload", 1, 1);
41 
42  arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
43  arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
44 
45  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
46  input.info()->set_data_layout(aclDataLayout);
47  output.info()->set_data_layout(aclDataLayout);
48 
49  int axis = (m_Data.m_Parameters.m_DataLayout == DataLayout::NCHW) ? 2 : 0;
50 
51  m_Layer.configure(clCompileContext, &input, &output, axis, m_Data.m_Parameters.m_Eps);
52 }
53 
55 {
56  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClL2NormalizationFloatWorkload_Execute", this->GetGuid());
57  RunClFunction(m_Layer, CHECK_LOCATION());
58 }
59 
60 } //namespace armnn
float m_Eps
Used to avoid dividing by zero.
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
arm_compute::Status ClL2NormalizationWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const L2NormalizationDescriptor &descriptor)
DataLayout
Definition: Types.hpp:53
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
ClL2NormalizationFloatWorkload(const L2NormalizationQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
A L2NormalizationDescriptor for the L2NormalizationLayer.
QueueDescriptor m_Data
Definition: Workload.hpp:58
Status
enumeration
Definition: Types.hpp:29
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
profiling::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:55
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