19 using namespace armnn;
34 const unsigned int batchSize = tensorShape[0];
35 const unsigned int depth = tensorShape[1];
36 const unsigned int rows = tensorShape[2];
37 const unsigned int cols = tensorShape[3];
39 int radius = armnn::numeric_cast<int>(norm_size / 2u);
41 for (
unsigned int n = 0; n < batchSize; n++)
43 for (
unsigned int c = 0; c < depth; c++)
45 for (
unsigned int h = 0; h < rows; h++)
47 for (
unsigned int w = 0; w < cols; w++)
49 float accumulated_scale = 0.0;
50 for (
int y = -radius; y <= radius; y++)
52 for (
int x = -radius; x <= radius; x++)
54 int i = armnn::numeric_cast<int>(w) + x;
55 int j = armnn::numeric_cast<int>(h) + y;
57 if ((i < 0) || (i >= armnn::numeric_cast<int>(cols)))
62 if ((j < 0) || (j >= armnn::numeric_cast<int>(rows)))
67 unsigned int inputIndex = n * cols * rows * depth +
69 armnn::numeric_cast<unsigned int>(j) * cols +
70 armnn::numeric_cast<unsigned int>(i);
71 inputData[inputIndex];
72 float inval = inputData.
Get();
74 accumulated_scale += inval*inval;
78 unsigned int index = n * cols * rows * depth +
84 outputData.
Set(inputData.
Get() / (powf((kappa + (accumulated_scale * alpha)), beta)));
103 const unsigned int batchSize = tensorShape[0];
104 const unsigned int depth = tensorShape[dataLayoutIndexed.GetChannelsIndex()];
105 const unsigned int rows = tensorShape[dataLayoutIndexed.GetHeightIndex()];
106 const unsigned int cols = tensorShape[dataLayoutIndexed.GetWidthIndex()];
108 int radius = armnn::numeric_cast<int>(norm_size / 2u);
110 for (
unsigned int n = 0; n < batchSize; n++)
112 for (
unsigned int c = 0; c < depth; c++)
114 for (
unsigned int h = 0; h < rows; h++)
116 for (
unsigned int w = 0; w < cols; w++)
118 float accumulated_scale = 0.0;
119 for (
int z = -radius; z <= radius; z++)
121 int k = armnn::numeric_cast<int>(c) + z;
123 if ((k < 0) || (k >= armnn::numeric_cast<int>(depth)))
128 unsigned inputIndex = dataLayoutIndexed.GetIndex(tensorShape,
130 armnn::numeric_cast<unsigned int>(k),
134 inputData[inputIndex];
135 float inval = inputData.
Get();
137 accumulated_scale += inval * inval;
140 float scale = kappa + (accumulated_scale * alpha);
141 scale = powf(scale, -beta);
143 unsigned index = dataLayoutIndexed.GetIndex(tensorShape, n, c, h, w);
147 outputData.
Set(scale * inputData.
Get());
181 auto inputDecoder = MakeDecoder<float>(inputInfo, inputs[0]->
Map());
182 auto outputEncoder = MakeEncoder<float>(inputInfo, outputs[0]->
Map());
188 NormalizeWithinUingLbr(*inputDecoder,
198 NormalizeAcrossUingLbr(*inputDecoder,
209 ARMNN_LOG(warning) <<
"Illegal NORMALIZATION mode in normalization_f32";
215 ARMNN_LOG(warning) <<
"Lcr method (Jarret 2009: Local Contrast Normalization) not supported yet.";