19 unsigned int channels,
23 unsigned int channelDimension3D = dataLayout.
GetDataLayout() == DataLayout::NCHW ? 1 : 2;
26 return (batch * shape[dataLayout.
GetHeightIndex()] + height) * shape[channelDimension3D] + channels;
57 if (rank != 3 && rank != 4 )
64 unsigned int channelDimension3D = params.
m_DataLayout == DataLayout::NCHW ? 1 : 2;
69 const unsigned int inputBatchSize = inputShape[0];
70 const unsigned int outputBatchSize = outputShape[0];
72 const unsigned int channels = (rank == 3) ? inputShape[channelDimension3D]
75 const unsigned int inputHeight = inputShape[dataLayout.
GetHeightIndex()];
76 const unsigned int inputWidth = (rank == 3) ? 1 : inputShape[dataLayout.
GetWidthIndex()];
77 const unsigned int outputHeight = outputShape[dataLayout.
GetHeightIndex()];
78 const unsigned int outputWidth = (rank == 3) ? 1 : outputShape[dataLayout.
GetWidthIndex()];
81 const unsigned int blockWidth = (rank == 3) ? 1 : params.
m_BlockShape[1];
83 const unsigned int cropsTop = params.
m_Crops[0].first;
84 const unsigned int cropsLeft = (rank == 3) ? 0 : params.
m_Crops[1].first;
86 for (
unsigned int inBatch = 0; inBatch < inputBatchSize; ++inBatch)
88 const unsigned int outBatch = inBatch % outputBatchSize;
89 const unsigned int spatialOffset = inBatch / outputBatchSize;
91 for (
unsigned int inH = 0; inH < inputHeight; ++inH)
93 const unsigned int outH = inH * blockHeight + spatialOffset / blockWidth - cropsTop;
95 if (outH >= outputHeight)
100 for (
unsigned int inW = 0; inW < inputWidth; ++inW)
102 const unsigned int outW = inW * blockWidth + spatialOffset % blockWidth - cropsLeft;
104 if (outW >= outputWidth)
109 for (
unsigned int c = 0; c < channels; c++)
111 unsigned int outOffset =
Offset(outputShape, outBatch, outH, outW, c, dataLayout);
112 unsigned int inOffset =
Offset(inputShape, inBatch, inH, inW, c, dataLayout);
114 outputData[outOffset];
116 outputData.
Set(inputData.
Get());