47 const unsigned int inputBatchSize = inputShape[0];
48 const unsigned int inputHeight = inputShape[dataLayout.
GetHeightIndex()];
49 const unsigned int inputWidth = inputShape[dataLayout.
GetWidthIndex()];
51 const unsigned int outputBatchSize = outputShape[0];
52 const unsigned int outputHeight = outputShape[dataLayout.
GetHeightIndex()];
53 const unsigned int outputWidth = outputShape[dataLayout.
GetWidthIndex()];
58 const unsigned int paddingTop = params.
m_PadList[0].first;
59 const unsigned int paddingLeft = params.
m_PadList[1].first;
61 for (
unsigned int outB = 0; outB < outputBatchSize; outB++)
63 unsigned int inB = outB % inputBatchSize;
65 unsigned int shiftW = (outB / inputBatchSize) % blockWidth;
66 unsigned int shiftH = (outB / inputBatchSize) / blockWidth;
68 for (
unsigned int outH = 0; outH < outputHeight; outH++)
70 for (
unsigned int outW = 0; outW < outputWidth; outW++)
72 if (outH * blockHeight + shiftH < paddingTop ||
73 outH * blockHeight + shiftH >= paddingTop + inputHeight ||
74 outW * blockWidth + shiftW < paddingLeft ||
75 outW * blockWidth + shiftW >= paddingLeft + inputWidth)
77 for (
unsigned int c = 0; c < channels; c++)
79 unsigned int outOffset =
GetOffset(outputShape,
85 outputData += outOffset;
87 outputData -= outOffset;
92 for (
unsigned int c = 0; c < channels; c++)
94 unsigned int inOffset =
GetOffset(inputShape,
96 (outH * blockHeight + shiftH) - paddingTop,
97 (outW * blockWidth + shiftW) - paddingLeft,
101 unsigned int outOffset =
GetOffset(outputShape,
108 outputData += outOffset;
109 inputData += inOffset;
110 outputData.
Set(inputData.
Get());
111 inputData -= inOffset;
112 outputData -= outOffset;
armnn::DataLayout GetDataLayout() const
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left, right}.
unsigned int GetHeightIndex() const
void SpaceToBatchNd(const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToBatchNdDescriptor ¶ms, Decoder< float > &inputData, Encoder< float > &outputData)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
std::vector< unsigned int > m_BlockShape
Block shape value.
unsigned int GetWidthIndex() const
unsigned int GetOffset(const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
unsigned int GetChannelsIndex() const
virtual IType Get() const =0
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
const TensorShape & GetShape() const
virtual void Set(IType right)=0