45 unsigned int paddedShapeArray[4];
48 const unsigned int batches = (idxShift == 0) ? shape[0] : 1;
49 paddedShapeArray[0] = batches;
52 const unsigned int channels = (channelsIdx - idxShift >= 0)
55 paddedShapeArray[channelsIdx] = channels;
58 const unsigned int height = (heightIdx - idxShift >= 0)
61 paddedShapeArray[heightIdx] = height;
64 const unsigned int width = (widthIdx - idxShift >= 0)
67 paddedShapeArray[widthIdx] = width;
71 for (
unsigned int n = 0; n < batches; ++n)
73 for (
unsigned int c = 0; c < channels; ++c)
75 for (
unsigned int h = 0; h < height; ++h)
77 for (
unsigned int w = 0; w < width; ++w)
79 float reduction = 0.0;
80 for (
unsigned int d = 0; d < channels; ++d)
82 unsigned int inputIndex = dataLayout.GetIndex(paddedShape, n, d, h, w);
84 (*inputDecoder)[inputIndex];
85 const float value = inputDecoder->Get();
86 reduction += value * value;
89 unsigned int index = dataLayout.GetIndex(paddedShape, n, c, h, w);
93 const float scale = 1.0f / sqrtf(
maximum);
95 (*inputDecoder)[index];
96 (*outputEncoder)[index];
97 outputEncoder->Set(inputDecoder->Get() * scale);
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
L2NormalizationQueueDescriptor m_Data
RefBaseWorkload(const L2NormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
RefL2NormalizationWorkload(const L2NormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
void Execute() const override
const TensorShape & GetShape() const
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout.
Copyright (c) 2021 ARM Limited and Contributors.
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
std::unique_ptr< Decoder< T > > MakeDecoder(const TensorInfo &info, const void *data=nullptr)
std::unique_ptr< Encoder< T > > MakeEncoder(const TensorInfo &info, void *data=nullptr)
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
float m_Eps
Used to avoid dividing by zero.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
LayerDescriptor m_Parameters
Contains information about TensorInfos of a layer.