protected final int outputFeatureMapLength;
protected final int outputFeatureMapColumns;
protected final int outputMiniBatchDistance;
public AparapiSubsampling2D(Subsampling2DConnection c, ValuesProvider valuesProvider, Layer targetLayer) {
Tensor input = null, output = null;
if (targetLayer == c.getOutputLayer()) {
input = TensorFactory.tensor(Util.getOppositeLayer(c, targetLayer), c, valuesProvider);
output = TensorFactory.tensor(targetLayer, c, valuesProvider);
} else {
input = TensorFactory.tensor(targetLayer, c, valuesProvider);
output = TensorFactory.tensor(Util.getOppositeLayer(c, targetLayer), c, valuesProvider);
}
this.input = input.getElements();
this.inputStartIndex = input.getStartIndex();
this.inputFeatureMapsDistance = input.getDimensionElementsDistance(0);
this.inputFeatureMapRowsDistance = input.getDimensionElementsDistance(1);
this.inputFeatureMapColumnsDistance = input.getDimensionElementsDistance(2);
this.output = output.getElements();
this.outputStartIndex = output.getStartIndex();
this.outputFeatureMapsDistance = output.getDimensionElementsDistance(0);
this.outputFeatureMapRowsDistance = output.getDimensionElementsDistance(1);
this.outputFeatureMapColumnsDistance = output.getDimensionElementsDistance(2);
this.outputMiniBatchDistance = output.getDimensionElementsDistance(3);
this.outputFeatureMapLength = c.getOutputFeatureMapLength();
this.outputFeatureMapColumns = c.getOutputFeatureMapColumns();
this.miniBatchSize = input.getDimensions()[3];
this.subsamplingRows = c.getSubsamplingRegionRows();
this.subsamplingCols = c.getSubsamplingRegionCols();
this.regionLength = c.getSubsamplingRegionLength();
this.ioRowsOffset = (c.getInputFeatureMapRows() % subsamplingRows) / 2;
this.ioColumnsOffset = (c.getInputFeatureMapColumns() % subsamplingCols) / 2;
this.featureMapOffsets = new int[regionLength * miniBatchSize];
int inputMiniBatchDistance = input.getDimensionElementsDistance(3);
for (int m = 0, i = 0; m < miniBatchSize; m++) {
for (int j = 0; j < subsamplingRows; j++) {
for (int k = 0; k < subsamplingCols; k++) {
featureMapOffsets[i++] = j * inputFeatureMapRowsDistance + k * inputFeatureMapColumnsDistance + m * inputMiniBatchDistance;
}