ArmNN
 25.11
Loading...
Searching...
No Matches
ClInstanceNormalizationWorkload.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
7#include "ClWorkloadUtils.hpp"
8
10
11#include <cl/ClTensorHandle.hpp>
12
13using namespace armnn::armcomputetensorutils;
14
15namespace armnn
16{
17
18arm_compute::Status ClInstanceNormalizationWorkloadValidate(const TensorInfo& input,
19 const TensorInfo& output,
20 const InstanceNormalizationDescriptor& descriptor)
21{
22 const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
23 const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
24
25 return arm_compute::CLInstanceNormalizationLayer::validate(&aclInputInfo,
26 &aclOutputInfo,
27 descriptor.m_Gamma,
28 descriptor.m_Beta,
29 descriptor.m_Eps);
30}
31
34 const WorkloadInfo& info,
35 const arm_compute::CLCompileContext& clCompileContext)
37{
38 // Report Profiling Details
39 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClInstanceNormalizationWorkload_Construct",
40 descriptor.m_Parameters,
41 info,
42 this->GetGuid());
43
44 m_Data.ValidateInputsOutputs("ClInstanceNormalizationWorkload", 1, 1);
45
46 arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
47 arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
48
49 arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
50 input.info()->set_data_layout(aclDataLayout);
51 output.info()->set_data_layout(aclDataLayout);
52
53 {
54 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClInstanceNormalizationWorkload_configure");
55 m_Layer.configure(clCompileContext,
56 &input,
57 &output,
58 descriptor.m_Parameters.m_Gamma,
59 descriptor.m_Parameters.m_Beta,
60 descriptor.m_Parameters.m_Eps);
61 }
62};
63
65{
66 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClInstanceNormalizationWorkload_Execute");
67 RunClFunction(m_Layer, CHECK_LOCATION());
68}
69
70} // 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)
ClBaseWorkload(const InstanceNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
ClInstanceNormalizationWorkload(const InstanceNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Copyright (c) 2021 ARM Limited and Contributors.
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
arm_compute::Status ClInstanceNormalizationWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const InstanceNormalizationDescriptor &descriptor)
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
float m_Eps
Epsilon, small scalar value added to variance to avoid dividing by zero. Defaults to 1e-12f.
float m_Gamma
Gamma, the scale scalar value applied for the normalized tensor. Defaults to 1.0.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
float m_Beta
Beta, the offset scalar value applied for the normalized tensor. Defaults to 1.0.
Contains information about TensorInfos of a layer.