Resize - version 11#

This page documents version 11 of operator Resize. See Resize for the latest version (since version 19).

  • Domain: ai.onnx

  • Since version: 11

Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor. Each dimension value of the output tensor is:

output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) if input \"sizes\" is not specified.

Inputs

  • X (T1): N-D tensor

  • roi (T2): 1-D tensor given as [start1, …, startN, end1, …, endN], where N is the rank of X. The RoIs’ coordinates are normalized in the coordinate system of the input image. It only takes effect when coordinate_transformation_mode is “tf_crop_and_resize”

  • scales (tensor(float)): The scale array along each dimension. It takes value greater than 0. If it’s less than 1, it’s sampling down, otherwise, it’s upsampling. The number of elements of ‘scales’ should be the same as the rank of input ‘X’. If ‘size’ is needed, the user must set ‘scales’ to an empty tensor.

  • sizes (tensor(int64)): The size of the output tensor. The number of elements of ‘sizes’ should be the same as the rank of input ‘X’. May only be set if ‘scales’ is set to an empty tensor.

Outputs

  • Y (T1): N-D tensor after resizing

Attributes

  • coordinate_transformation_mode (string): Describes how to transform coordinates between the resized and original tensor (e.g. half_pixel, asymmetric, align_corners, pytorch_half_pixel, tf_crop_and_resize, tf_half_pixel_for_nn).

  • cubic_coeff_a (float): The coefficient ‘a’ used in cubic interpolation. Two common choice are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for the details. This attribute is valid only if “mode” is “cubic”.

  • exclude_outside (int): If set to 1, the weight of sampling locations outside the tensor will be set to 0 and the weight will be renormalized so that their sum is 1.0. The default value is 0.

  • extrapolation_value (float): When coordinate_transformation_mode is “tf_crop_and_resize” and x_original is outside the range [0, length_original - 1], this value is used as the corresponding output value. Default is 0.0f.

  • mode (string): Three interpolation modes: nearest (default), linear and cubic. The “linear” mode includes linear interpolation for 1D tensor and N-linear interpolation for N-D tensor (for example, bilinear interpolation for 2D tensor). The “cubic” mode includes cubic interpolation for 1D tensor and N-cubic interpolation for N-D tensor (for example, bicubic interpolation for 2D tensor).

  • nearest_mode (string): Four modes: round_prefer_floor (default, as known as round half down), round_prefer_ceil (as known as round half up), floor, ceil. Only used by nearest interpolation. It indicates how to get “nearest” pixel in input tensor from x_original, so this attribute is valid only if “mode” is “nearest”.

Type Constraints

  • T1: 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).

  • T2: Constrain roi type to float or double. Allowed types: tensor(double), tensor(float), tensor(float16).

Differences with previous version (10)#

SchemaDiff: Resize (domain 'ai.onnx')

  • old version: 10

  • new version: 11

  • breaking: yes

Breaking reasons:

  • input ‘roi’ (added): at position 1; option=Single; type_str=’T2’

  • input ‘sizes’ (added): at position 3; option=Single; type_str=’tensor(int64)’

  • input ‘X’ (changed): type_str changed ‘T’ -> ‘T1’

  • input ‘scales’ (changed): position changed 1 -> 2

  • output ‘Y’ (changed): type_str changed ‘T’ -> ‘T1’

  • type constraint ‘T’ (removed): entire constraint removed

Inputs:

  • [BREAKING] added ‘roi’: at position 1; option=Single; type_str=’T2’

  • [BREAKING] added ‘sizes’: at position 3; option=Single; type_str=’tensor(int64)’

  • [BREAKING] changed ‘X’: type_str changed ‘T’ -> ‘T1’

  • [BREAKING] changed ‘scales’: position changed 1 -> 2

Outputs:

  • [BREAKING] changed ‘Y’: type_str changed ‘T’ -> ‘T1’

Attributes:

  • added ‘cubic_coeff_a’: type=FLOAT; required=False; default=-0.75

  • added ‘exclude_outside’: type=INT; required=False; default=0

  • added ‘coordinate_transformation_mode’: type=STRING; required=False; default=half_pixel

  • added ‘nearest_mode’: type=STRING; required=False; default=round_prefer_floor

  • added ‘extrapolation_value’: type=FLOAT; required=False; default=0

Type constraints:

  • [BREAKING] removed ‘T’: entire constraint removed

  • added ‘T1’: added 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)’]

  • added ‘T2’: added types: [‘tensor(double)’, ‘tensor(float)’, ‘tensor(float16)’]

Documentation:

  • line similarity: 0.50 (+2/-2 lines)

--- Resize v10
+++ Resize v11
@@ -1,4 +1,4 @@

-Resize the input tensor.
+Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor.
 Each dimension value of the output tensor is:
-  output_dimension = floor(input_dimension * scale).
+  output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) if input \"sizes\" is not specified.