31 unsigned int inputBatches = inputShape[0];
32 unsigned int inputHeight = inputShape[dataLayout.
GetHeightIndex()];
33 unsigned int inputWidth = inputShape[dataLayout.
GetWidthIndex()];
36 for (
unsigned int c = 0; c < inputChannels; c++)
42 float mean = meanDecoder.
Get();
43 float var = varianceDecoder.
Get();
44 float beta = betaDecoder.
Get();
45 float gamma = gammaDecoder.
Get();
48 float add = beta - mult * mean;
50 for (
unsigned int n = 0; n < inputBatches; n++)
52 for (
unsigned int h = 0; h < inputHeight; h++)
54 for (
unsigned int w = 0; w < inputWidth; w++)
56 unsigned int index = dataLayout.
GetIndex(inputShape, n, c, h, w);
59 outputEncoder.
Set(mult * inputDecoder.
Get() + add);
virtual IType Get() const =0
virtual void Set(IType right)=0
const TensorShape & GetShape() const
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout.
unsigned int GetIndex(const armnn::TensorShape &shape, unsigned int batchIndex, unsigned int channelIndex, unsigned int heightIndex, unsigned int widthIndex) const
unsigned int GetWidthIndex() const
unsigned int GetHeightIndex() const
unsigned int GetChannelsIndex() const
Copyright (c) 2021 ARM Limited and Contributors.
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
void BatchNormImpl(const BatchNormalizationQueueDescriptor &data, Decoder< float > &meanDecoder, Decoder< float > &varianceDecoder, Decoder< float > &betaDecoder, Decoder< float > &gammaDecoder, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< ITensorHandle * > m_Inputs
LayerDescriptor m_Parameters