Resize

Description

Adjusts the input tensor size.

Input

  • ONNX Opset v10

    Two inputs:

    x: tensor of type uint8, int8, int16, int32, int64, float16, float or double.

    scales: array with the same rank as input x.

  • When the ONNX version is Opset v11/v12/v14/v15/v16/v17:

    Two inputs:

    x: tensor of type float16 or float.

    sizes: size of the output tensor.

Output

One output:

y: tensor after resizing.

Attribute

  • ONNX Opset v10

    mode: string, interpolation algorithm. The value can be nearest or linear. The default value is nearest.

  • When the ONNX version is Opset v11/v12/v14/v15/v16/v17:
    • coordinate_transformation_mode: string, coordinate conversion between the resized image and the original image. The value can be align_corners, asymmetric, tf_half_pixel_for_nn, tf_crop_and_resize, pytorch_half_pixel or half_pixel. The default value is half_pixel.
    • cubic_coeff_a: A float, specifying the cubic interpolation coefficient. Defaults to -0.75.
    • exclude_outside: int, specifying the weight outside the tensor. Defaults to 0.
    • mode: string, interpolation algorithm. The value can be nearest, linear, or cubic. The default value is nearest.

Constraints

  • Currently, only the nearest and linear interpolation modes are supported to process images. In addition, you need to modify the model to change the input scales or sizes from placeholder to const. You can use onnxsimplifier to simplify the model.
  • 5D input
    • Currently, only the linear interpolation mode is supported, that is, mode=linear. mode=nearest and mode=cubic are not supported.
    • In linear interpolation mode, only the coordinate_transformation_mode=align_corners and pytorch_half_pixel coordinate modes are supported.

ONNX Opset Support

Opset v10/v11/v12/v14/v15/v16/v17