SpaceToBatch

Versioned name: SpaceToBatch-2

Category: Data movement

Short description: The SpaceToBatch operation divides "spatial" dimensions [1, ..., N - 1] of the data input into a grid of blocks of shape block_shape, and interleaves these blocks with the batch dimension (0) such that in the output, the spatial dimensions [1, ..., N - 1] correspond to the position within the grid, and the batch dimension combines both the position within a spatial block and the original batch position. Prior to division into blocks, the spatial dimensions of the input are optionally zero padded according to pads_begin and pads_end.

Detailed description:

The SpaceToBatch operation is similar to the TensorFlow* operation SpaceToBatchND

The operation is equivalent to the following transformation of the input tensor data of shape [batch, D_1, D_2 ... D_{N - 1}] and block_shape, pads_begin, pads_end of shapes [N] to Y output tensor.

Zero-pad the start and end of dimensions [D_0, ..., D_{N - 1}] of the input according to `pads_begin` and `pads_end`:
note: P_0 for batch dimension is expected to be 0 (no-padding).
x = [batch + P_0, D_1 + P_1, D_2 + P_2, ..., D_{N - 1} + P_{N - 1}], where P_i = pads_begin[i] + pads_end[i]

note: B_0 for batch is ignored.
x' = reshape(x, [batch, (D_1 + P_1) / B_1, B_1, (D_2 + P_2) / B_2, B_2, ..., (D_{N - 1} + P_{N - 1}) / B_{N - 1}, B_{N - 1}]), where B_i = block_shape[i]

x'' = transpose(x',  [2, 4, ..., (N - 1) + (N - 1), 0, 1, 3, ..., N + (N - 1)])

y = reshape(x'', [batch * B_1 * ... * B_{N - 1}, (D_1 + P_1) / B_1, (D_2 + P_2) / B_2, ... , (D_{N - 1} + P_{N - 1}) / B_{N - 1}])

Attributes

No attributes available.

Inputs

Outputs

Types

Example

<layer type="SpaceToBatch" ...>
<input>
<port id="0">
<dim>2</dim>
<dim>6</dim>
<dim>10</dim>
<dim>3</dim>
<dim>3</dim>
</port>
<port id="1">
<dim>5</dim>
</port>
<port id="2">
<dim>5</dim>
</port>
<port id="3">
<dim>5</dim>
</port>
</input>
<output>
<port id="3">
<dim>48</dim>
<dim>3</dim>
<dim>3</dim>
<dim>1</dim>
<dim>3</dim>
</port>
</output>
</layer>