SpaceToDepth#
Domain:
ai.onnxSince version: 13
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.
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.
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_cc_spacetodepth
Node:
SpaceToDepth(input) -> (output)
Attributes:
blocksize = 2
Inputs:
input: shape=(2, 3, 4, 6), dtype=float32
[[[[ 0., 1., 2., 3., 4., 5.],
[ 6., 7., 8., 9., 10., 11.],
[ 12., 13., 14., 15., 16., 17.],
[ 18., 19., 20., 21., 22., 23.]],
[[ 24., 25., 26., 27., 28., 29.],
[ 30., 31., 32., 33., 34., 35.],
[ 36., 37., 38., 39., 40., 41.],
[ 42., 43., 44., 45., 46., 47.]],
[[ 48., 49., 50., 51., 52., 53.],
[ 54., 55., 56., 57., 58., 59.],
[ 60., 61., 62., 63., 64., 65.],
[ 66., 67., 68., 69., 70., 71.]]],
[[[ 72., 73., 74., 75., 76., 77.],
[ 78., 79., 80., 81., 82., 83.],
[ 84., 85., 86., 87., 88., 89.],
[ 90., 91., 92., 93., 94., 95.]],
[[ 96., 97., 98., 99., 100., 101.],
[102., 103., 104., 105., 106., 107.],
[108., 109., 110., 111., 112., 113.],
[114., 115., 116., 117., 118., 119.]],
[[120., 121., 122., 123., 124., 125.],
[126., 127., 128., 129., 130., 131.],
[132., 133., 134., 135., 136., 137.],
[138., 139., 140., 141., 142., 143.]]]]
Outputs:
output: shape=(2, 12, 2, 3), dtype=float32
[[[[ 0., 2., 4.],
[ 12., 14., 16.]],
[[ 24., 26., 28.],
[ 36., 38., 40.]],
[[ 48., 50., 52.],
[ 60., 62., 64.]],
...,
[[ 7., 9., 11.],
[ 19., 21., 23.]],
[[ 31., 33., 35.],
[ 43., 45., 47.]],
[[ 55., 57., 59.],
[ 67., 69., 71.]]],
[[[ 72., 74., 76.],
[ 84., 86., 88.]],
[[ 96., 98., 100.],
[108., 110., 112.]],
[[120., 122., 124.],
[132., 134., 136.]],
...,
[[ 79., 81., 83.],
[ 91., 93., 95.]],
[[103., 105., 107.],
[115., 117., 119.]],
[[127., 129., 131.],
[139., 141., 143.]]]]
test_cc_spacetodepth_example
Node:
SpaceToDepth(input) -> (output)
Attributes:
blocksize = 2
Inputs:
input: shape=(1, 2, 2, 4), dtype=float32
[[[[ 0., 1., 2., 3.],
[ 4., 5., 6., 7.]],
[[ 8., 9., 10., 11.],
[12., 13., 14., 15.]]]]
Outputs:
output: shape=(1, 8, 1, 2), dtype=float32
[[[[ 0., 2.]],
[[ 8., 10.]],
[[ 1., 3.]],
[[ 9., 11.]],
[[ 4., 6.]],
[[12., 14.]],
[[ 5., 7.]],
[[13., 15.]]]]
Differences with previous version (1)#
SchemaDiff: SpaceToDepth (domain 'ai.onnx')
old version: 1
new version: 13
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(bfloat16)’]