Add DepthToSpace Operator
Description
Here is the ONNX description of the DeptthToSpace Operator
Summary
DepthToSpace rearranges (permutes) data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions. By default, mode = DCR. In the DCR mode, elements along the depth dimension from the input tensor are rearranged in the following order: depth, column, and then row. The output y is computed from the input x as below:
b, c, h, w = x.shape
tmp = np.reshape(x, [b, blocksize, blocksize, c // (blocksize**2), h, w])
tmp = np.transpose(tmp, [0, 3, 4, 1, 5, 2])
y = np.reshape(tmp, [b, c // (blocksize**2), h * blocksize, w * blocksize])
In the CRD mode, elements along the depth dimension from the input tensor are rearranged in the following order: column, row, and the depth. The output y is computed from the input x as below:
b, c, h, w = x.shape
tmp = np.reshape(x, [b, c // (blocksize ** 2), blocksize, blocksize, h, w])
tmp = np.transpose(tmp, [0, 1, 4, 2, 5, 3])
y = np.reshape(tmp, [b, c // (blocksize ** 2), h * blocksize, w * blocksize])
Attributes
- blocksize - INT (required) : Blocks of [blocksize, blocksize] are moved.
- mode - STRING (default is 'DCR'): DCR (default) for depth-column-row order re-arrangement. Use CRD for column-row-depth order.
Inputs
- input (heterogeneous) - T: Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.
Outputs
- output (heterogeneous) - T: Output tensor of [N, C/(blocksize * blocksize), H * blocksize, W * blocksize].
This operator is also available in Pytorch as PixelShuffle
Proposal
Create an Operator called DepthToSpace (better name to describe what it does).