Upsample - version 9#
This page documents version 9 of operator Upsample. See Upsample for the latest version (since version 10).
Domain:
ai.onnxSince version: 9
Upsample the input tensor. Each dimension value of the output tensor is:
output_dimension = floor(input_dimension * scale).
Inputs
X (T): N-D tensor
scales (tensor(float)): The scale array along each dimension. It takes value greater than or equal to 1. The number of elements of ‘scales’ should be the same as the rank of input ‘X’.
Outputs
Y (T): N-D tensor after resizing
Attributes
mode (string): Two interpolation modes: nearest (default), and linear (including bilinear, trilinear, etc)
Type Constraints
T: Constrain input ‘X’ and output ‘Y’ 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).
Examples#
test_cc_upsample_linear
Node:
Upsample(X, scales) -> (Y)
Attributes:
mode = "linear"
Inputs:
X: shape=(1, 1, 2, 2), dtype=float32
[[[[1., 2.],
[3., 4.]]]]
scales: shape=(4,), dtype=float32
[1., 1., 2., 2.]
Outputs:
Y: shape=(1, 1, 4, 4), dtype=float32
[[[[1. , 1.5, 2. , 2. ],
[2. , 2.5, 3. , 3. ],
[3. , 3.5, 4. , 4. ],
[3. , 3.5, 4. , 4. ]]]]
test_cc_upsample_nearest
Node:
Upsample(X, scales) -> (Y)
Attributes:
mode = "nearest"
Inputs:
X: shape=(1, 1, 2, 2), dtype=float32
[[[[1., 2.],
[3., 4.]]]]
scales: shape=(4,), dtype=float32
[1., 1., 2., 3.]
Outputs:
Y: shape=(1, 1, 4, 6), dtype=float32
[[[[1., 1., 1., 2., 2., 2.],
[1., 1., 1., 2., 2., 2.],
[3., 3., 3., 4., 4., 4.],
[3., 3., 3., 4., 4., 4.]]]]
test_cc_upsample_nearest_1d
Node:
Upsample(X, scales) -> (Y)
Attributes:
mode = "nearest"
Inputs:
X: shape=(3,), dtype=float32
[10., 20., 30.]
scales: shape=(1,), dtype=float32
[2.]
Outputs:
Y: shape=(6,), dtype=float32
[10., 10., 20., 20., 30., 30.]
test_cc_upsample_nearest_default_mode
Node:
Upsample(X, scales) -> (Y)
Inputs:
X: shape=(1, 1, 2, 2), dtype=float32
[[[[1., 2.],
[3., 4.]]]]
scales: shape=(4,), dtype=float32
[1., 1., 2., 2.]
Outputs:
Y: shape=(1, 1, 4, 4), dtype=float32
[[[[1., 1., 2., 2.],
[1., 1., 2., 2.],
[3., 3., 4., 4.],
[3., 3., 4., 4.]]]]
Differences with previous version (7)#
SchemaDiff: Upsample (domain 'ai.onnx')
old version: 7
new version: 9
breaking: yes
Breaking reasons:
input ‘scales’ (added): at position 1; option=Single; type_str=’tensor(float)’
attribute ‘scales’ (removed): type=FLOATS; required=True
Inputs:
[BREAKING] added ‘scales’: at position 1; option=Single; type_str=’tensor(float)’
Attributes:
[BREAKING] removed ‘scales’: type=FLOATS; required=True