45 auto inputDecoder = MakeDecoder<float>(inputInfo, inputs[0]->
Map());
46 auto outputEncoder = MakeEncoder<float>(outputInfo, outputs[0]->
Map());
51 unsigned int paddedShapeArray[4];
54 const unsigned int batches = (idxShift == 0) ? shape[0] : 1;
55 paddedShapeArray[0] = batches;
57 const int channelsIdx = armnn::numeric_cast<int>(dataLayout.GetChannelsIndex());
58 const unsigned int channels = (channelsIdx - idxShift >= 0)
59 ? shape[armnn::numeric_cast<unsigned int>(channelsIdx - idxShift)]
61 paddedShapeArray[channelsIdx] = channels;
63 const int heightIdx = armnn::numeric_cast<int>(dataLayout.GetHeightIndex());
64 const unsigned int height = (heightIdx - idxShift >= 0)
65 ? shape[armnn::numeric_cast<unsigned int>(heightIdx - idxShift)]
67 paddedShapeArray[heightIdx] = height;
69 const int widthIdx = armnn::numeric_cast<int>(dataLayout.GetWidthIndex());
70 const unsigned int width = (widthIdx - idxShift >= 0)
71 ? shape[armnn::numeric_cast<unsigned int>(widthIdx - idxShift)]
73 paddedShapeArray[widthIdx] = width;
77 for (
unsigned int n = 0; n < batches; ++n)
79 for (
unsigned int c = 0; c < channels; ++c)
81 for (
unsigned int h = 0; h < height; ++h)
83 for (
unsigned int w = 0; w < width; ++w)
85 float reduction = 0.0;
86 for (
unsigned int d = 0; d < channels; ++d)
88 unsigned int inputIndex = dataLayout.GetIndex(paddedShape, n, d, h, w);
90 (*inputDecoder)[inputIndex];
91 const float value = inputDecoder->Get();
92 reduction += value * value;
95 unsigned int index = dataLayout.GetIndex(paddedShape, n, c, h, w);
99 const float scale = 1.0f / sqrtf(
maximum);
101 (*inputDecoder)[index];
102 (*outputEncoder)[index];
103 outputEncoder->Set(inputDecoder->Get() * scale);