39 auto inputDecoder = MakeDecoder<float>(inputInfo, inputs[0]->
Map());
40 auto outputEncoder = MakeEncoder<float>(outputInfo, outputs[0]->
Map());
45 unsigned int paddedShapeArray[4];
48 const unsigned int batches = (idxShift == 0) ? shape[0] : 1;
49 paddedShapeArray[0] = batches;
51 const int channelsIdx = armnn::numeric_cast<int>(dataLayout.GetChannelsIndex());
52 const unsigned int channels = (channelsIdx - idxShift >= 0)
53 ? shape[armnn::numeric_cast<unsigned int>(channelsIdx - idxShift)]
55 paddedShapeArray[channelsIdx] = channels;
57 const int heightIdx = armnn::numeric_cast<int>(dataLayout.GetHeightIndex());
58 const unsigned int height = (heightIdx - idxShift >= 0)
59 ? shape[armnn::numeric_cast<unsigned int>(heightIdx - idxShift)]
61 paddedShapeArray[heightIdx] = height;
63 const int widthIdx = armnn::numeric_cast<int>(dataLayout.GetWidthIndex());
64 const unsigned int width = (widthIdx - idxShift >= 0)
65 ? shape[armnn::numeric_cast<unsigned int>(widthIdx - idxShift)]
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);
91 float maximum = reduction <
m_Data.m_Parameters.m_Eps ?
m_Data.m_Parameters.m_Eps : reduction;
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.
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.
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
std::vector< ITensorHandle * > m_Inputs
std::vector< ITensorHandle * > m_Outputs
Contains information about TensorInfos of a layer.