:nosearch: .. _op_ai_onnx_DepthToSpace-11: DepthToSpace - version 11 ========================= This page documents version **11** of operator **DepthToSpace**. See :doc:`DepthToSpace` for the latest version (since version 13). - **Domain**: ``ai.onnx`` - **Since version**: 11 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]) **Inputs** - **input** (*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** (*T*): Output tensor of [N, C/(blocksize \* blocksize), H \* blocksize, W \* blocksize]. **Attributes** - **blocksize** (*int*): Blocks of [blocksize, blocksize] are moved. - **mode** (*string*): DCR (default) for depth-column-row order re-arrangement. Use CRD for column-row-depth order. **Type Constraints** - **T**: Constrain input and output types to all tensor types. Allowed types: tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8). Differences with previous version (1) ------------------------------------- **SchemaDiff**: ``DepthToSpace`` (domain ``'ai.onnx'``) * old version: 1 * new version: 11 * breaking: no **Attributes:** * added 'mode': type=STRING; required=False; default=DCR **Documentation:** * line similarity: 0.19 (+24/-1 lines) .. code-block:: diff --- DepthToSpace v1 +++ DepthToSpace v11 @@ -1,4 +1,27 @@ 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. +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]) +