19 inline unsigned int Offset(
const TensorShape& shape,
unsigned int batch,
unsigned int height,
unsigned int width,
38 const std::vector<unsigned int>& blockShape,
39 const std::vector<std::pair<unsigned int, unsigned int>>& cropsData,
51 const unsigned int inputBatchSize = inputShape[0];
54 const unsigned int outputBatchSize = outputShape[0];
55 const unsigned int outputHeight = outputShape[dataLayout.
GetHeightIndex()];
56 const unsigned int outputWidth = outputShape[dataLayout.
GetWidthIndex()];
58 ARMNN_ASSERT_MSG(blockShape.size() > 0,
"BlockShape must contain 1 or more entries");
60 const unsigned int blockShapeHeight = blockShape[0];
61 const unsigned int blockShapeWidth = blockShape[1];
63 ARMNN_ASSERT_MSG(cropsData.size() > 0,
"Crops must contain 1 or more entries");
65 const unsigned int cropsTop = cropsData[0].first;
66 const unsigned int cropsLeft = cropsData[1].first;
68 for (
unsigned int inBatch = 0; inBatch < inputBatchSize; ++inBatch)
70 const unsigned int outBatch = inBatch % outputBatchSize;
71 const unsigned int spatialOffset = inBatch / outputBatchSize;
74 const unsigned int outH = inH * blockShapeHeight + spatialOffset / blockShapeWidth - cropsTop;
76 if (outH >= outputHeight)
82 const unsigned int outW = inW * blockShapeWidth + spatialOffset % blockShapeWidth - cropsLeft;
84 if (outW >= outputWidth)
89 for (
unsigned int c = 0; c < channels; c++)
91 unsigned int outOffset =
Offset(outputShape, outBatch, outH, outW, c, dataLayout);
92 unsigned int inOffset =
Offset(inputShape, inBatch, inH, inW, c, dataLayout);
94 outputEncoder[outOffset];
95 inputDecoder[inOffset];
96 outputEncoder.
Set(inputDecoder.
Get());