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];
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++)
67 unsigned int inputIndex = n * cols * rows * depth +
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()];
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++)
128 unsigned inputIndex = dataLayoutIndexed.GetIndex(tensorShape,
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());
182 NormalizeWithinUingLbr(*inputDecoder,
192 NormalizeAcrossUingLbr(*inputDecoder,
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.
NormalizationQueueDescriptor m_Data
virtual IType Get() const =0
virtual void Set(IType right)=0
RefBaseWorkload(const NormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
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.
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)
@ LocalBrightness
Krichevsky 2012: Local Brightness Normalization.
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
NormalizationAlgorithmMethod m_NormMethodType
Normalization method algorithm to use (LocalBrightness, LocalContrast).
float m_Alpha
Alpha value for the normalization equation.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
float m_Beta
Beta value for the normalization equation.
float m_K
Kappa value used for the across channel normalization equation.
uint32_t m_NormSize
Depth radius value.
NormalizationAlgorithmChannel m_NormChannelType
Normalization channel algorithm to use (Across, Within).
LayerDescriptor m_Parameters
Contains information about TensorInfos of a layer.