SpaceToDepth#

  • Domain: ai.onnx

  • Since version: 28

SpaceToDepth rearranges blocks of spatial data into depth. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension. mode determines whether blocks are ordered depth-column-row (DCR, the default) or column-row-depth (CRD).

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(bfloat16), 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).

Examples#

test_spacetodepth_crd_mode_example

Node:
  SpaceToDepth(input) -> (output)
  Attributes:
    blocksize = 2
    mode = "CRD"
Inputs:
  input: shape=(1, 2, 4, 6), dtype=float32
    [[[[ 0.,  9.,  1., 10.,  2., 11.],
       [18., 27., 19., 28., 20., 29.],
       [ 3., 12.,  4., 13.,  5., 14.],
       [21., 30., 22., 31., 23., 32.]],

      [[36., 45., 37., 46., 38., 47.],
       [54., 63., 55., 64., 56., 65.],
       [39., 48., 40., 49., 41., 50.],
       [57., 66., 58., 67., 59., 68.]]]]

Outputs:
  output: shape=(1, 8, 2, 3), dtype=float32
    [[[[ 0.,  1.,  2.],
       [ 3.,  4.,  5.]],

      [[ 9., 10., 11.],
       [12., 13., 14.]],

      [[18., 19., 20.],
       [21., 22., 23.]],

      [[27., 28., 29.],
       [30., 31., 32.]],

      [[36., 37., 38.],
       [39., 40., 41.]],

      [[45., 46., 47.],
       [48., 49., 50.]],

      [[54., 55., 56.],
       [57., 58., 59.]],

      [[63., 64., 65.],
       [66., 67., 68.]]]]

test_spacetodepth_dcr_mode_example

Node:
  SpaceToDepth(input) -> (output)
  Attributes:
    blocksize = 2
    mode = "DCR"
Inputs:
  input: shape=(1, 2, 4, 6), dtype=float32
    [[[[ 0., 18.,  1., 19.,  2., 20.],
       [36., 54., 37., 55., 38., 56.],
       [ 3., 21.,  4., 22.,  5., 23.],
       [39., 57., 40., 58., 41., 59.]],

      [[ 9., 27., 10., 28., 11., 29.],
       [45., 63., 46., 64., 47., 65.],
       [12., 30., 13., 31., 14., 32.],
       [48., 66., 49., 67., 50., 68.]]]]

Outputs:
  output: shape=(1, 8, 2, 3), dtype=float32
    [[[[ 0.,  1.,  2.],
       [ 3.,  4.,  5.]],

      [[ 9., 10., 11.],
       [12., 13., 14.]],

      [[18., 19., 20.],
       [21., 22., 23.]],

      [[27., 28., 29.],
       [30., 31., 32.]],

      [[36., 37., 38.],
       [39., 40., 41.]],

      [[45., 46., 47.],
       [48., 49., 50.]],

      [[54., 55., 56.],
       [57., 58., 59.]],

      [[63., 64., 65.],
       [66., 67., 68.]]]]

Differences with previous version (13)#

SchemaDiff: SpaceToDepth (domain 'ai.onnx')

  • old version: 13

  • new version: 28

  • breaking: no

Attributes:

  • added ‘mode’: type=STRING; required=False; default=DCR

Documentation:

  • line similarity: 0.57 (+2/-1 lines)

--- SpaceToDepth v13
+++ SpaceToDepth v28
@@ -1,3 +1,4 @@
 SpaceToDepth rearranges blocks of spatial data into depth. More specifically,
 this op outputs a copy of the input tensor where values from the height and width dimensions
-are moved to the depth dimension.
+are moved to the depth dimension. `mode` determines whether blocks are ordered depth-column-row
+(`DCR`, the default) or column-row-depth (`CRD`).

Version History#