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);
unsigned int GetHeightIndex() const
LayerDescriptor m_Parameters
unsigned int GetWidthIndex() const
float m_Eps
Value to add to the variance. Used to avoid dividing by zero.
unsigned int GetChannelsIndex() const
void BatchNormImpl(const BatchNormalizationQueueDescriptor &data, Decoder< float > &meanDecoder, Decoder< float > &varianceDecoder, Decoder< float > &betaDecoder, Decoder< float > &gammaDecoder, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
virtual IType Get() const =0
std::vector< ITensorHandle * > m_Inputs
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
const TensorShape & GetShape() const
virtual void Set(IType right)=0
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
unsigned int GetIndex(const armnn::TensorShape &shape, unsigned int batchIndex, unsigned int channelIndex, unsigned int heightIndex, unsigned int widthIndex) const