47 const unsigned int inputBatchSize = inputShape[0];
48 const unsigned int inputChannels = inputShape[dataLayout.
GetChannelsIndex()];
50 const unsigned int outputHeight = outputShape[dataLayout.
GetHeightIndex()];
51 const unsigned int outputWidth = outputShape[dataLayout.
GetWidthIndex()];
52 const unsigned int outputChannels = outputShape[dataLayout.
GetChannelsIndex()];
59 "Input shape must be divisible by block size in all spatial dimensions: Block size is"
63 for (
unsigned int outChannelIndex = 0; outChannelIndex < outputChannels; outChannelIndex++)
65 unsigned int inChannelIndex = outChannelIndex % inputChannels;
67 unsigned int shiftW = (outChannelIndex / inputChannels) % blockSize;
68 unsigned int shiftH = (outChannelIndex / inputChannels) / blockSize;
70 for (
unsigned int outH = 0; outH < outputHeight; outH++)
72 for (
unsigned int outW = 0; outW < outputWidth; outW++)
74 for (
unsigned int inBatchIndex = 0; inBatchIndex < inputBatchSize; inBatchIndex++)
76 unsigned int inOffset =
GetOffset(inputShape,
78 (outH * blockSize + shiftH),
79 (outW * blockSize + shiftW),
83 unsigned int outOffset =
GetOffset(outputShape,
90 outputData += outOffset;
91 inputData += inOffset;
92 outputData.
Set(inputData.
Get());
93 inputData -= inOffset;
94 outputData -= outOffset;
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 GetWidthIndex() const
unsigned int GetHeightIndex() const
armnn::DataLayout GetDataLayout() const
unsigned int GetChannelsIndex() const
Copyright (c) 2021 ARM Limited and Contributors.
void SpaceToDepth(const TensorInfo &inputInfo, const TensorInfo &outputInfo, const SpaceToDepthDescriptor ¶ms, Decoder< float > &inputData, Encoder< float > &outputData)
unsigned int GetOffset(const TensorShape &shape, unsigned int b, unsigned int h, unsigned int w, unsigned int c, const DataLayoutIndexed &dataLayout)
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.