BatchToSpace

Versioned name: BatchToSpace-2

Category: Data movement

Short description: The BatchToSpace operation reshapes the "batch" dimension 0 into N - 1 dimensions of shape block_shape + [batch] and interleaves these blocks back into the grid defined by the spatial dimensions [1, ..., N - 1] to obtain a result with the same rank as data input. The spatial dimensions of this intermediate result are then optionally cropped according to crops_begin and crops_end to produce the output. This is the reverse of the SpaceToBatch operation.

Detailed description:

The BatchToSpace operation is similar to the TensorFlow* operation BatchToSpaceND

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

note: B_0 is expected to be 1.
x' = reshape(`data`, [B_1, ..., B_{N - 1}, batch / (B_1 * ... B_{N - 1}), D_1, D_2, ..., D_{N - 1}]), where B_i = block_shape[i]

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

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

Crop the start and end of dimensions according to crops_begin, crops_end to produce the output of shape: note: crops_begin[0], crops_end[0] are expected to be 0. y = [batch / (B_1 * ... * B_{N - 1}), crop(D_1 * B_1, crops_begin[1], crops_end[1]), crop(D_2 * B_2, crops_begin[2], crops_end[2]), ... , crop(D_{N - 1} * B_{N - 1}, crops_begin[N - 1], crops_end[N - 1])]

Attributes

No attributes available.

Inputs

Outputs

Types

Example

<layer type="BatchToSpace" ...>
<input>
<port id="0">
<dim>48</dim>
<dim>3</dim>
<dim>3</dim>
<dim>1</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>2</dim>
<dim>6</dim>
<dim>10</dim>
<dim>3</dim>
<dim>3</dim>
</port>
</output>
</layer>