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());
175 auto inputDecoder = MakeDecoder<float>(inputInfo, inputs[0]->
Map());
176 auto outputEncoder = MakeEncoder<float>(inputInfo, outputs[0]->
Map());
182 NormalizeWithinUingLbr(*inputDecoder,
185 m_Data.m_Parameters.m_NormSize,
186 m_Data.m_Parameters.m_Alpha,
187 m_Data.m_Parameters.m_Beta,
192 NormalizeAcrossUingLbr(*inputDecoder,
195 m_Data.m_Parameters.m_NormSize,
196 m_Data.m_Parameters.m_Alpha,
197 m_Data.m_Parameters.m_Beta,
199 m_Data.m_Parameters.m_DataLayout);
203 ARMNN_LOG(warning) <<
"Illegal NORMALIZATION mode in normalization_f32";
209 ARMNN_LOG(warning) <<
"Lcr method (Jarret 2009: Local Contrast Normalization) not supported yet.";
#define ARMNN_LOG(severity)
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
virtual IType Get() const =0
virtual void Set(IType right)=0
void Execute() const override
RefNormalizationWorkload(const NormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
const TensorShape & GetShape() const
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
@ LocalBrightness
Krichevsky 2012: Local Brightness Normalization.
std::vector< ITensorHandle * > m_Inputs
std::vector< ITensorHandle * > m_Outputs
Contains information about TensorInfos of a layer.