44 auto inputDecoder = MakeDecoder<float>(inputInfo, inputs[0]->Map());
45 auto outputEncoder = MakeEncoder<float>(outputInfo, outputs[0]->Map());
50 unsigned int paddedShapeArray[4];
53 const unsigned int batches = (idxShift == 0) ? shape[0] : 1;
54 paddedShapeArray[0] = batches;
57 const unsigned int channels = (channelsIdx - idxShift >= 0)
58 ? shape[armnn::numeric_cast<unsigned int>(channelsIdx - idxShift)]
60 paddedShapeArray[channelsIdx] = channels;
63 const unsigned int height = (heightIdx - idxShift >= 0)
64 ? shape[armnn::numeric_cast<unsigned int>(heightIdx - idxShift)]
66 paddedShapeArray[heightIdx] = height;
69 const unsigned int width = (widthIdx - idxShift >= 0)
70 ? shape[armnn::numeric_cast<unsigned int>(widthIdx - idxShift)]
72 paddedShapeArray[widthIdx] = width;
76 for (
unsigned int n = 0; n < batches; ++n)
78 for (
unsigned int c = 0; c < channels; ++c)
80 for (
unsigned int h = 0; h < height; ++h)
82 for (
unsigned int w = 0; w < width; ++w)
84 float reduction = 0.0;
85 for (
unsigned int d = 0; d < channels; ++d)
87 unsigned int inputIndex = dataLayout.GetIndex(paddedShape, n, d, h, w);
89 (*inputDecoder)[inputIndex];
90 const float value = inputDecoder->Get();
91 reduction += value * value;
94 unsigned int index = dataLayout.GetIndex(paddedShape, n, c, h, w);
98 const float scale = 1.0f / sqrtf(maximum);
100 (*inputDecoder)[index];
101 (*outputEncoder)[index];
102 outputEncoder->Set(inputDecoder->Get() * scale);
float m_Eps
Used to avoid dividing by zero.
CPU Execution: Reference C++ kernels.
Copyright (c) 2021 ARM Limited and Contributors.
LayerDescriptor m_Parameters
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< ITensorHandle * > m_Inputs
L2NormalizationQueueDescriptor m_Data
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
void Execute() const override
std::vector< ITensorHandle * > m_Outputs
void ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) override
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
RefL2NormalizationWorkload(const L2NormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
std::vector< ITensorHandle * > m_Outputs
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers