30 const unsigned int heightIndex = dataLayoutIndexed.
GetHeightIndex();
31 const unsigned int widthIndex = dataLayoutIndexed.
GetWidthIndex();
33 unsigned int numBatches = inputShape[0];
35 unsigned int inputWidth = inputShape[widthIndex];
36 unsigned int inputHeight = inputShape[heightIndex];
37 unsigned int inputDepth = inputShape[channelsIndex];
39 unsigned int weightsHeight = weightsShape[heightIndex];
40 unsigned int weightsWidth = weightsShape[widthIndex];
42 unsigned int outputHeight = outputShape[heightIndex];
43 unsigned int outputWidth = outputShape[widthIndex];
44 unsigned int outputDepth = outputShape[channelsIndex];
46 unsigned int paddingLeft = descriptor.
m_PadLeft;
47 unsigned int paddingTop = descriptor.
m_PadTop;
49 unsigned int strideX = descriptor.
m_StrideX;
50 unsigned int strideY = descriptor.
m_StrideY;
54 for (
unsigned int batch = 0u; batch < numBatches; ++batch)
56 for (
unsigned int yInput = 0u; yInput < inputHeight; ++yInput)
58 for (
unsigned int xInput = 0u; xInput < inputWidth; ++xInput)
60 unsigned int xOutputOrigin = xInput * strideX - paddingLeft;
61 unsigned int yOutputOrigin = yInput * strideY - paddingTop;
63 for (
unsigned int dOutput = 0u; dOutput < outputDepth; ++dOutput)
65 for (
unsigned int yWeights = 0u; yWeights < weightsHeight; ++yWeights)
67 for (
unsigned int xWeights = 0u; xWeights < weightsWidth; ++xWeights)
69 unsigned int yOutput = yOutputOrigin + yWeights;
70 unsigned int xOutput = xOutputOrigin + xWeights;
72 if (yOutput < outputHeight && xOutput< outputWidth)
74 for (
unsigned int dInput = 0u; dInput < inputDepth; dInput++)
76 const unsigned int inputIndex =
77 dataLayoutIndexed.
GetIndex(inputShape, batch, dInput, yInput, xInput);
78 inputDecoder[inputIndex];
80 const unsigned int weightsIndex =
81 dataLayoutIndexed.
GetIndex(weightsShape, dOutput, dInput, yWeights, xWeights);
82 weightsDecoder.
SetIndex(weightsIndex, dOutput);
84 const unsigned int outputIndex =
85 dataLayoutIndexed.
GetIndex(outputShape, batch, dOutput, yOutput, xOutput);
86 outputEncoder[outputIndex];
88 float output = outputBuffer[outputIndex];
89 output += inputDecoder.
Get() * weightsDecoder.
Get();
90 outputBuffer[outputIndex] = output;
106 for (
unsigned int batch = 0u; batch < numBatches; ++batch)
108 for (
unsigned int dOutput = 0u; dOutput < outputDepth; ++dOutput)
110 rBiasesDecoder.
SetIndex(dOutput, dOutput);
111 for (
unsigned int yOutput = 0u; yOutput < outputHeight; ++yOutput)
113 for (
unsigned int xOutput = 0u; xOutput < outputWidth; ++xOutput)
115 const unsigned int outputIndex =
116 dataLayoutIndexed.
GetIndex(outputShape, batch, dOutput, yOutput, xOutput);
117 outputBuffer[outputIndex] += rBiasesDecoder.
Get();
124 for (
float output : outputBuffer)
126 outputEncoder.
Set(output);
uint32_t m_PadTop
Padding top value in the height dimension.
unsigned int GetHeightIndex() const
void TransposeConvolution2dImpl(const TransposeConvolution2dDescriptor &descriptor, const TensorShape &inputShape, Decoder< float > &inputDecoder, const TensorShape &outputShape, Encoder< float > &outputEncoder, const TensorShape &weightsShape, Decoder< float > &weightsDecoder, Decoder< float > *biasesDecoder)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
virtual BaseIterator & SetIndex(unsigned int index, unsigned int axisIndex=0)=0
unsigned int GetWidthIndex() const
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
unsigned int GetNumElements() const
unsigned int GetChannelsIndex() const
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
virtual IType Get() const =0
bool m_BiasEnabled
Enable/disable bias.
virtual void Set(IType right)=0
unsigned int GetIndex(const armnn::TensorShape &shape, unsigned int batchIndex, unsigned int channelIndex, unsigned int heightIndex, unsigned int widthIndex) const