Resize#

  • Domain: ai.onnx

  • Since version: 19

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 or the length of axes, if provided. 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’ or the length of ‘axes’, if provided. One of ‘scales’ and ‘sizes’ MUST be specified and it is an error if both are specified. If ‘sizes’ is needed, the user can use an empty string as the name of ‘scales’ in this operator’s input list.

  • sizes (tensor(int64)): Target size of the output tensor. Its interpretation depends on the ‘keep_aspect_ratio_policy’ value.The number of elements of ‘sizes’ should be the same as the rank of input ‘X’, or the length of ‘axes’, if provided. Only one of ‘scales’ and ‘sizes’ can be specified.

Outputs

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

Attributes

  • antialias (int): If set to 1, “linear” and “cubic” interpolation modes will use an antialiasing filter when downscaling. Antialiasing is achieved by stretching the resampling filter by a factor max(1, 1 / scale), which means that when downsampling, more input pixels contribute to an output pixel.

  • axes (int[]): If provided, it specifies a subset of axes that ‘roi’, ‘scales’ and ‘sizes’ refer to. If not provided, all axes are assumed [0, 1, …, r-1], where r = rank(data). Non-specified dimensions are interpreted as non-resizable. Negative value means counting dimensions from the back. Accepted range is [-r, r-1], where r = rank(data). Behavior is undefined if an axis is repeated.

  • coordinate_transformation_mode (string): Describes how to transform coordinates between the resized and original tensor.

  • 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.

  • keep_aspect_ratio_policy (string): This attribute describes how to interpret the sizes input with regard to keeping the original aspect ratio of the input, and it is not applicable when the sizes input is not provided.

  • 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(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).

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

Examples#

test_resize_downsample_scales_cubic

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1. , 1. , 0.8, 0.8]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 1.4711914,  2.78125  ,  4.0825195],
       [ 6.711426 ,  8.021484 ,  9.322754 ],
       [11.916504 , 13.2265625, 14.527832 ]]]]

test_resize_downsample_scales_cubic_A_n0p5_exclude_outside

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    cubic_coeff_a = -0.5
    exclude_outside = 1
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1. , 1. , 0.8, 0.8]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 1.3681267,  2.6695013,  4.0133367],
       [ 6.573625 ,  7.875    ,  9.218835 ],
       [11.948966 , 13.250341 , 14.594176 ]]]]

test_resize_downsample_scales_cubic_align_corners

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    coordinate_transformation_mode = "align_corners"
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1. , 1. , 0.8, 0.8]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 1.       ,  2.3951917,  3.790383 ],
       [ 6.580766 ,  7.975958 ,  9.371149 ],
       [12.161532 , 13.556724 , 14.951916 ]]]]

test_resize_downsample_scales_cubic_antialias

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    antialias = 1
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1. , 1. , 0.6, 0.6]

Outputs:
  Y: shape=(1, 1, 2, 2), dtype=float32
    [[[[ 2.5180721,  4.2858863],
       [ 9.589329 , 11.357142 ]]]]

test_resize_downsample_scales_linear

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    mode = "linear"
Inputs:
  X: shape=(1, 1, 2, 4), dtype=float32
    [[[[1., 2., 3., 4.],
       [5., 6., 7., 8.]]]]
  scales: shape=(4,), dtype=float32
    [1. , 1. , 0.6, 0.6]

Outputs:
  Y: shape=(1, 1, 1, 2), dtype=float32
    [[[[2.6666665, 4.333333 ]]]]

test_resize_downsample_scales_linear_align_corners

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    coordinate_transformation_mode = "align_corners"
    mode = "linear"
Inputs:
  X: shape=(1, 1, 2, 4), dtype=float32
    [[[[1., 2., 3., 4.],
       [5., 6., 7., 8.]]]]
  scales: shape=(4,), dtype=float32
    [1. , 1. , 0.6, 0.6]

Outputs:
  Y: shape=(1, 1, 1, 2), dtype=float32
    [[[[1.      , 3.142857]]]]

test_resize_downsample_scales_linear_antialias

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    antialias = 1
    mode = "linear"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1. , 1. , 0.6, 0.6]

Outputs:
  Y: shape=(1, 1, 2, 2), dtype=float32
    [[[[ 2.875,  4.5  ],
       [ 9.375, 11.   ]]]]

test_resize_downsample_scales_linear_half_pixel_symmetric

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    coordinate_transformation_mode = "half_pixel_symmetric"
    mode = "linear"
Inputs:
  X: shape=(1, 1, 1, 4), dtype=float32
    [[[[1., 2., 3., 4.]]]]
  scales: shape=(4,), dtype=float32
    [1. , 1. , 1. , 0.6]

Outputs:
  Y: shape=(1, 1, 1, 2), dtype=float32
    [[[[1.6666667, 3.3333333]]]]

test_resize_downsample_sizes_cubic

Node:
  Resize(X, "", "", sizes) -> (Y)
  Attributes:
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  sizes: shape=(4,), dtype=int64
    [1, 1, 3, 3]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 1.630787 ,  3.0046296,  4.3784723],
       [ 7.1261573,  8.5      ,  9.873842 ],
       [12.621528 , 13.99537  , 15.369213 ]]]]

test_resize_downsample_sizes_cubic_antialias

Node:
  Resize(X, "", "", sizes) -> (Y)
  Attributes:
    antialias = 1
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  sizes: shape=(4,), dtype=int64
    [1, 1, 3, 3]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 1.7750092,  3.1200073,  4.4650054],
       [ 7.1550016,  8.5      ,  9.844998 ],
       [12.534994 , 13.8799925, 15.224991 ]]]]

test_resize_downsample_sizes_linear_antialias

Node:
  Resize(X, "", "", sizes) -> (Y)
  Attributes:
    antialias = 1
    mode = "linear"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  sizes: shape=(4,), dtype=int64
    [1, 1, 3, 3]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 2.3636363,  3.590909 ,  4.818182 ],
       [ 7.2727275,  8.5      ,  9.727273 ],
       [12.181818 , 13.409091 , 14.636364 ]]]]

test_resize_downsample_sizes_linear_pytorch_half_pixel

Node:
  Resize(X, "", "", sizes) -> (Y)
  Attributes:
    coordinate_transformation_mode = "pytorch_half_pixel"
    mode = "linear"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  sizes: shape=(4,), dtype=int64
    [1, 1, 3, 1]

Outputs:
  Y: shape=(1, 1, 3, 1), dtype=float32
    [[[[ 1.6666666],
       [ 7.       ],
       [12.333333 ]]]]

test_resize_tf_crop_and_resize

Node:
  Resize(X, roi, "", sizes) -> (Y)
  Attributes:
    coordinate_transformation_mode = "tf_crop_and_resize"
    mode = "linear"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  roi: shape=(8,), dtype=float32
    [0. , 0. , 0.4, 0.6, 1. , 1. , 0.6, 0.8]
  sizes: shape=(4,), dtype=int64
    [1, 1, 3, 3]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 7.6000004,  7.9      ,  8.2      ],
       [ 8.8      ,  9.1      ,  9.400001 ],
       [10.       , 10.3      , 10.6      ]]]]

test_resize_tf_crop_and_resize_axes_2_3

Node:
  Resize(X, roi, "", sizes) -> (Y)
  Attributes:
    axes = [2, 3]
    coordinate_transformation_mode = "tf_crop_and_resize"
    mode = "linear"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  roi: shape=(4,), dtype=float32
    [0.4, 0.6, 0.6, 0.8]
  sizes: shape=(2,), dtype=int64
    [3, 3]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 7.6000004,  7.9      ,  8.2      ],
       [ 8.8      ,  9.1      ,  9.400001 ],
       [10.       , 10.3      , 10.6      ]]]]

test_resize_tf_crop_and_resize_axes_3_2

Node:
  Resize(X, roi, "", sizes) -> (Y)
  Attributes:
    axes = [3, 2]
    coordinate_transformation_mode = "tf_crop_and_resize"
    mode = "linear"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  roi: shape=(4,), dtype=float32
    [0.6, 0.4, 0.8, 0.6]
  sizes: shape=(2,), dtype=int64
    [3, 3]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 7.6000004,  7.9      ,  8.2      ],
       [ 8.8      ,  9.1      ,  9.400001 ],
       [10.       , 10.3      , 10.6      ]]]]

test_resize_tf_crop_and_resize_extrapolation_value

Node:
  Resize(X, roi, "", sizes) -> (Y)
  Attributes:
    coordinate_transformation_mode = "tf_crop_and_resize"
    extrapolation_value = 10.0
    mode = "linear"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  roi: shape=(8,), dtype=float32
    [0. , 0. , 0.4, 0.6, 1. , 1. , 1.2, 1.7]
  sizes: shape=(4,), dtype=int64
    [1, 1, 3, 3]

Outputs:
  Y: shape=(1, 1, 3, 3), dtype=float32
    [[[[ 7.6000004, 10.       , 10.       ],
       [12.400001 , 10.       , 10.       ],
       [10.       , 10.       , 10.       ]]]]

test_resize_upsample_scales_cubic

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1., 1., 2., 2.]

Outputs:
  Y: shape=(1, 1, 8, 8), dtype=float32
    [[[[ 0.47265625,  0.76953125,  1.2460938 ,  1.875     ,  2.28125   ,
         2.9101562 ,  3.3867188 ,  3.6835938 ],
       [ 1.6601562 ,  1.9570312 ,  2.4335938 ,  3.0625    ,  3.46875   ,
         4.0976562 ,  4.5742188 ,  4.8710938 ],
       [ 3.5664062 ,  3.8632812 ,  4.3398438 ,  4.96875   ,  5.375     ,
         6.0039062 ,  6.4804688 ,  6.7773438 ],
       [ 6.0820312 ,  6.3789062 ,  6.8554688 ,  7.484375  ,  7.890625  ,
         8.519531  ,  8.996094  ,  9.292969  ],
       [ 7.7070312 ,  8.003906  ,  8.480469  ,  9.109375  ,  9.515625  ,
        10.144531  , 10.621094  , 10.917969  ],
       [10.222656  , 10.519531  , 10.996094  , 11.625     , 12.03125   ,
        12.660156  , 13.136719  , 13.433594  ],
       [12.128906  , 12.425781  , 12.902344  , 13.53125   , 13.9375    ,
        14.566406  , 15.042969  , 15.339844  ],
       [13.316406  , 13.613281  , 14.089844  , 14.71875   , 15.125     ,
        15.753906  , 16.230469  , 16.527344  ]]]]

test_resize_upsample_scales_cubic_A_n0p5_exclude_outside

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    cubic_coeff_a = -0.5
    exclude_outside = 1
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1., 1., 2., 2.]

Outputs:
  Y: shape=(1, 1, 8, 8), dtype=float32
    [[[[ 0.5588235 ,  0.81494206,  1.3569825 ,  1.8970588 ,  2.3970587 ,
         2.9371352 ,  3.4791756 ,  3.735294  ],
       [ 1.5832976 ,  1.839416  ,  2.3814566 ,  2.9215329 ,  3.4215329 ,
         3.9616091 ,  4.5036497 ,  4.759768  ],
       [ 3.7514594 ,  4.007578  ,  4.5496182 ,  5.0896945 ,  5.5896945 ,
         6.1297708 ,  6.6718116 ,  6.92793   ],
       [ 5.9117646 ,  6.1678834 ,  6.7099237 ,  7.25      ,  7.75      ,
         8.290076  ,  8.832117  ,  9.088235  ],
       [ 7.9117646 ,  8.167883  ,  8.709924  ,  9.25      ,  9.75      ,
        10.290076  , 10.832117  , 11.088235  ],
       [10.07207   , 10.328189  , 10.870229  , 11.410305  , 11.910305  ,
        12.450381  , 12.992422  , 13.248541  ],
       [12.2402315 , 12.49635   , 13.038391  , 13.578467  , 14.078467  ,
        14.618544  , 15.1605835 , 15.416702  ],
       [13.264706  , 13.520824  , 14.062865  , 14.6029415 , 15.1029415 ,
        15.643018  , 16.185059  , 16.441177  ]]]]

test_resize_upsample_scales_cubic_align_corners

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    coordinate_transformation_mode = "align_corners"
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1., 1., 2., 2.]

Outputs:
  Y: shape=(1, 1, 8, 8), dtype=float32
    [[[[ 1.       ,  1.3411078,  1.8002915,  2.329446 ,  2.670554 ,  3.1997085,
         3.6588922,  4.       ],
       [ 2.3644314,  2.7055395,  3.164723 ,  3.6938775,  4.0349855,  4.56414  ,
         5.0233235,  5.3644314],
       [ 4.201166 ,  4.542274 ,  5.0014577,  5.5306125,  5.8717203,  6.4008746,
         6.8600583,  7.201166 ],
       [ 6.3177843,  6.658892 ,  7.118076 ,  7.64723  ,  7.988338 ,  8.517492 ,
         8.976676 ,  9.317784 ],
       [ 7.6822157,  8.023324 ,  8.482508 ,  9.011662 ,  9.35277  ,  9.881925 ,
        10.341108 , 10.682216 ],
       [ 9.798834 , 10.139941 , 10.599125 , 11.12828  , 11.469388 , 11.998542 ,
        12.457726 , 12.798834 ],
       [11.635569 , 11.976676 , 12.43586  , 12.965014 , 13.306123 , 13.835277 ,
        14.29446  , 14.635569 ],
       [13.       , 13.341108 , 13.800292 , 14.329446 , 14.670554 , 15.199708 ,
        15.658892 , 16.       ]]]]

test_resize_upsample_scales_cubic_asymmetric

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    coordinate_transformation_mode = "asymmetric"
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  scales: shape=(4,), dtype=float32
    [1., 1., 2., 2.]

Outputs:
  Y: shape=(1, 1, 8, 8), dtype=float32
    [[[[ 1.     ,  1.40625,  2.     ,  2.5    ,  3.     ,  3.59375,  4.     ,
         4.09375],
       [ 2.625  ,  3.03125,  3.625  ,  4.125  ,  4.625  ,  5.21875,  5.625  ,
         5.71875],
       [ 5.     ,  5.40625,  6.     ,  6.5    ,  7.     ,  7.59375,  8.     ,
         8.09375],
       [ 7.     ,  7.40625,  8.     ,  8.5    ,  9.     ,  9.59375, 10.     ,
        10.09375],
       [ 9.     ,  9.40625, 10.     , 10.5    , 11.     , 11.59375, 12.     ,
        12.09375],
       [11.375  , 11.78125, 12.375  , 12.875  , 13.375  , 13.96875, 14.375  ,
        14.46875],
       [13.     , 13.40625, 14.     , 14.5    , 15.     , 15.59375, 16.     ,
        16.09375],
       [13.375  , 13.78125, 14.375  , 14.875  , 15.375  , 15.96875, 16.375  ,
        16.46875]]]]

test_resize_upsample_scales_linear

Node:
  Resize(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.25, 1.75, 2.  ],
       [1.5 , 1.75, 2.25, 2.5 ],
       [2.5 , 2.75, 3.25, 3.5 ],
       [3.  , 3.25, 3.75, 4.  ]]]]

test_resize_upsample_scales_linear_align_corners

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    coordinate_transformation_mode = "align_corners"
    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.3333334, 1.6666666, 2.       ],
       [1.6666666, 2.       , 2.3333333, 2.6666667],
       [2.3333333, 2.6666667, 3.       , 3.3333333],
       [3.       , 3.3333333, 3.6666667, 4.       ]]]]

test_resize_upsample_scales_linear_half_pixel_symmetric

Node:
  Resize(X, "", scales) -> (Y)
  Attributes:
    coordinate_transformation_mode = "half_pixel_symmetric"
    mode = "linear"
Inputs:
  X: shape=(1, 1, 2, 2), dtype=float32
    [[[[1., 2.],
       [3., 4.]]]]
  scales: shape=(4,), dtype=float32
    [1.  , 1.  , 2.3 , 2.94]

Outputs:
  Y: shape=(1, 1, 4, 5), dtype=float32
    [[[[1.       , 1.159864 , 1.5      , 1.840136 , 2.       ],
       [1.5652174, 1.7250813, 2.0652175, 2.4053535, 2.5652175],
       [2.4347825, 2.5946465, 2.9347825, 3.2749186, 3.4347825],
       [3.       , 3.159864 , 3.5      , 3.840136 , 4.       ]]]]

test_resize_upsample_sizes_cubic

Node:
  Resize(X, "", "", sizes) -> (Y)
  Attributes:
    mode = "cubic"
Inputs:
  X: shape=(1, 1, 4, 4), dtype=float32
    [[[[ 1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.],
       [ 9., 10., 11., 12.],
       [13., 14., 15., 16.]]]]
  sizes: shape=(4,), dtype=int64
    [ 1,  1,  9, 10]

Outputs:
  Y: shape=(1, 1, 9, 10), dtype=float32
    [[[[ 0.45507923,  0.6405792 ,  0.9715792 , ...,  3.1590793 ,  3.4900792 ,
         3.6755793 ],
       [ 1.3943796 ,  1.5798796 ,  1.9108796 , ...,  4.0983796 ,  4.4293795 ,
         4.6148796 ],
       [ 2.9513068 ,  3.136807  ,  3.4678068 , ...,  5.655307  ,  5.986307  ,
         6.171807  ],
       ...,
       [10.828193  , 11.013693  , 11.344693  , ..., 13.532193  , 13.8631935 ,
        14.048693  ],
       [12.38512   , 12.570621  , 12.90162   , ..., 15.08912   , 15.42012   ,
        15.60562   ],
       [13.324421  , 13.509921  , 13.84092   , ..., 16.028421  , 16.35942   ,
        16.54492   ]]]]

Differences with previous version (18)#

SchemaDiff: Resize (domain 'ai.onnx')

  • old version: 18

  • new version: 19

  • breaking: no

Documentation:

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

--- Resize v18
+++ Resize v19
@@ -1,5 +1,7 @@

 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: <br/>
-  `output_dimension = floor(input_dimension * (roi_end - roi_start) * scale)` <br/>
+Each dimension value of the output tensor is:
+```
+output_dimension = floor(input_dimension * (roi_end - roi_start) * scale)
+```
 if input \"sizes\" is not specified.

Version History#