ArmNN
 25.11
Loading...
Searching...
No Matches
ClNormalizationFloatWorkload.cpp
Go to the documentation of this file.
1//
2// Copyright © 2017-2018,2020-2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
12#include "ClWorkloadUtils.hpp"
13
14using namespace armnn::armcomputetensorutils;
15
16namespace armnn
17{
18
19arm_compute::Status ClNormalizationWorkloadValidate(const TensorInfo& input,
20 const TensorInfo& output,
21 const NormalizationDescriptor& descriptor)
22{
23 const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
24 const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
25
26 arm_compute::NormalizationLayerInfo layerInfo = BuildArmComputeNormalizationLayerInfo(descriptor);
27
28 return arm_compute::CLNormalizationLayer::validate(&aclInputInfo, &aclOutputInfo, layerInfo);
29}
30
32 const WorkloadInfo& info,
33 const arm_compute::CLCompileContext& clCompileContext)
35{
36 // Report Profiling Details
37 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClNormalizationWorkload_Construct",
38 descriptor.m_Parameters,
39 info,
40 this->GetGuid());
41
42 m_Data.ValidateInputsOutputs("ClNormalizationFloatWorkload", 1, 1);
43
44 arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
45 arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
46
47 arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
48 input.info()->set_data_layout(aclDataLayout);
49 output.info()->set_data_layout(aclDataLayout);
50
51 arm_compute::NormalizationLayerInfo normalizationInfo = BuildArmComputeNormalizationLayerInfo(m_Data.m_Parameters);
52
53 {
54 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClNormalizationFloatWorkload_configure");
55 m_NormalizationLayer.configure(clCompileContext, &input, &output, normalizationInfo);
56 }
57};
58
60{
61 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClNormalizationFloatWorkload_Execute");
62 RunClFunction(m_NormalizationLayer, CHECK_LOCATION());
63}
64
66{
67 ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot];
68 this->m_Data.m_Inputs[slot] = tensorHandle;
69 try
70 {
71 Reconfigure();
72 }
74 {
75 // Cannot reconfigure, revert the slot back and throw the exception.
76 this->m_Data.m_Inputs[slot] = backupHandle;
77 throw e;
78 }
79}
80
81// Replace output tensor handle with the given TensorHandle
83{
84 ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot];
85 this->m_Data.m_Inputs[slot] = tensorHandle;
86 try
87 {
88 Reconfigure();
89 }
91 {
92 // Cannot reconfigure, revert the slot back and throw the exception.
93 this->m_Data.m_Inputs[slot] = backupHandle;
94 throw e;
95 }
96}
97
98void ClNormalizationFloatWorkload::Reconfigure()
99{
100 throw armnn::UnimplementedException("Reconfigure not implemented for this workload");
101}
102
103} //namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
#define CHECK_LOCATION()
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
QueueDescriptor m_Data
Definition Workload.hpp:74
void ReplaceInputTensorHandle(ITensorHandle *tensorHandle, unsigned int slot) override
void ReplaceOutputTensorHandle(ITensorHandle *tensorHandle, unsigned int slot) override
ClNormalizationFloatWorkload(const NormalizationQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Copyright (c) 2021 ARM Limited and Contributors.
arm_compute::Status ClNormalizationWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const NormalizationDescriptor &descriptor)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
TypedWorkload< QueueDescriptor, armnn::DataType::Float16, armnn::DataType::Float32 > FloatWorkload
Definition Workload.hpp:195
A NormalizationDescriptor for the NormalizationLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Contains information about TensorInfos of a layer.