Resize - 11 vs 18#

Next section compares an older to a newer version of the same operator after both definition are converted into markdown text. Green means an addition to the newer version, red means a deletion. Anything else is unchanged.

Files changed (1) hide show
  1. Resize11 → Resize18 +41 -80
Resize11 → Resize18 RENAMED
@@ -1 +1 @@
1
1
  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.
2
- Each dimension value of the output tensor is: <br/>
2
+ Each dimension value of the output tensor is:
3
- output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) <br/>
3
+ output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) if input "sizes" is not specified.
4
- if input "sizes" is not specified.
5
4
  **Attributes**
6
- * **antialias**:
7
- If set to 1, "linear" and "cubic" interpolation modes will use an
8
- antialiasing filter when downscaling. Antialiasing is achieved by
9
- stretching the resampling filter by a factor max(1, 1 / scale),
10
- which means that when downsampling, more input pixels contribute to
11
- an output pixel.
12
- * **axes**:
13
- If provided, it specifies a subset of axes that 'roi', 'scales' and
14
- 'sizes' refer to. If not provided, all axes are assumed [0, 1, ...,
15
- r-1], where r = rank(data). Non-specified dimensions are interpreted
16
- as non-resizable. Negative value means counting dimensions from the
17
- back. Accepted range is [-r, r-1], where r = rank(data). Behavior is
18
- undefined if an axis is repeated.
19
5
  * **coordinate_transformation_mode**:
20
6
  This attribute describes how to transform the coordinate in the
21
7
  resized tensor to the coordinate in the original tensor. <br/> The
22
8
  coordinate of each dimension is transformed individually. Let's
23
9
  describe a case using axis x as an example. Denote x_resized as the
24
10
  coordinate of axis x in the resized tensor, x_original as the
25
- coordinate of axis x in the original tensor, length_original as
11
+ coordinate of axis x in the original tensor, length_original as the
26
- the length of the original tensor in axis x, length_resized as the
12
+ length of the original tensor in axis x, length_resized as the
27
13
  length of the resized tensor in axis x, roi_x = (start_x, end_x) of
28
- the axis x in input "roi", scale = length_resized /
14
+ the axis x in input "roi", scale = length_resized / length_original,
29
- length_original, <br/> if coordinate_transformation_mode is
30
- "half_pixel", <br/> x_original = (x_resized + 0.5) / scale - 0.5
31
- <br/> if coordinate_transformation_mode is "pytorch_half_pixel",
15
+ <br/> if coordinate_transformation_mode is "half_pixel", <br/>
16
+ x_original = (x_resized + 0.5) / scale - 0.5, <br/> if
17
+ coordinate_transformation_mode is "pytorch_half_pixel", <br/>
32
- <br/> x_original = length_resized > 1 ? (x_resized + 0.5) / scale -
18
+ x_original = length_resized > 1 ? (x_resized + 0.5) / scale - 0.5 :
33
- 0.5 : 0 <br/> if coordinate_transformation_mode is
19
+ 0, <br/> if coordinate_transformation_mode is "align_corners",
34
- "align_corners", <br/> x_original = x_resized * (length_original
20
+ <br/> x_original = x_resized * (length_original - 1) /
35
- - 1) / (length_resized - 1) <br/> if
36
- coordinate_transformation_mode is "asymmetric", <br/> x_original
37
- = x_resized / scale <br/> if coordinate_transformation_mode is
21
+ (length_resized - 1), <br/> if coordinate_transformation_mode is
38
- "tf_crop_and_resize", <br/> x_original = length_resized > 1 ?
22
+ "asymmetric", <br/> x_original = x_resized / scale, <br/> if
23
+ coordinate_transformation_mode is "tf_half_pixel_for_nn", <br/>
24
+ x_original = (x_resized + 0.5) / scale, <br/> if
25
+ coordinate_transformation_mode is "tf_crop_and_resize", <br/>
39
- start_x * (length_original - 1) + x_resized * (end_x - start_x) *
26
+ x_original = length_resized > 1 ? start_x * (length_original - 1) +
40
- (length_original - 1) / (length_resized - 1) : 0.5 * (start_x +
41
- end_x) * (length_original - 1) .
27
+ x_resized * (end_x - start_x) * (length_original - 1) /
28
+ (length_resized - 1) : 0.5 * (start_x + end_x) * (length_original -
29
+ 1).
42
30
  * **cubic_coeff_a**:
43
31
  The coefficient 'a' used in cubic interpolation. Two common choice
44
32
  are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check
45
33
  out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for
46
- the details. This attribute is valid only if mode is "cubic".
34
+ the details. This attribute is valid only if "mode" is "cubic".
47
35
  * **exclude_outside**:
48
36
  If set to 1, the weight of sampling locations outside the tensor
49
37
  will be set to 0 and the weight will be renormalized so that their
50
38
  sum is 1.0. The default value is 0.
51
39
  * **extrapolation_value**:
52
40
  When coordinate_transformation_mode is "tf_crop_and_resize" and
53
41
  x_original is outside the range [0, length_original - 1], this value
54
42
  is used as the corresponding output value. Default is 0.0f.
55
- * **keep_aspect_ratio_policy**:
56
- This attribute describes how to interpret the sizes input with
57
- regard to keeping the original aspect ratio of the input, and it is
58
- not applicable when the scales input is used. <br/> Given a set
59
- of sizes, associated with a subset of axes (explicitly provided
60
- or default), and assuming d = axes[i], with i being the index of
61
- the provided sizes. <br/> If keep_aspect_ratio_policy is
62
- "stretch", the original aspect ratio is disregarded, and the input
63
- is resized to the specified size: <br/> out_size[d] = sizes[i]
64
- <br/> If keep_aspect_ratio_policy is "not_larger", the sizes
65
- are adjusted so that no extent of the output is larger than the
66
- specified size, while keeping the original aspect ratio: <br/>
67
- scale = Min(sizes[i] / in_size[d]) <br/> out_size[d] =
68
- round_int(scale * in_size[i]) <br/> If keep_aspect_ratio_policy
69
- is "not_smaller", the sizes are adjusted so that no extent of the
70
- output is smaller than the specified size, while keeping the
71
- original aspect ratio: <br/> scale = Max(sizes[i] / in_size[d])
72
- <br/> out_size[d] = round_int(scale * in_size[i]) <br/> For non-
73
- resizable axes (those not specified in axes), the output size will
74
- be equal to the input size. Note: round_int stands for computing
75
- the nearest integer value, rounding halfway cases up.
76
43
  * **mode**:
77
- Three interpolation modes: "nearest" (default), "linear" and
44
+ Three interpolation modes: nearest (default), linear and cubic. The
78
- "cubic". The "linear" mode includes linear interpolation for 1D
45
+ "linear" mode includes linear interpolation for 1D tensor and
79
- tensor and N-linear interpolation for N-D tensor (for example,
46
+ N-linear interpolation for N-D tensor (for example, bilinear
80
- bilinear interpolation for 2D tensor). The "cubic" mode includes
47
+ interpolation for 2D tensor). The "cubic" mode includes cubic
81
- cubic interpolation for 1D tensor and N-cubic interpolation for N-D
48
+ interpolation for 1D tensor and N-cubic interpolation for N-D tensor
82
- tensor (for example, bicubic interpolation for 2D tensor).
49
+ (for example, bicubic interpolation for 2D tensor).
83
50
  * **nearest_mode**:
84
- Four modes: "round_prefer_floor" (default, as known as round half
51
+ Four modes: round_prefer_floor (default, as known as round half
85
- down), "round_prefer_ceil" (as known as round half up), "floor",
52
+ down), round_prefer_ceil (as known as round half up), floor, ceil.
86
- "ceil". Only used by nearest interpolation. It indicates how to get
53
+ Only used by nearest interpolation. It indicates how to get
87
54
  "nearest" pixel in input tensor from x_original, so this attribute
88
55
  is valid only if "mode" is "nearest".
89
56
  **Inputs**
90
- Between 1 and 4 inputs.
57
+ Between 3 and 4 inputs.
91
58
  * **X** (heterogeneous) - **T1**:
92
59
  N-D tensor
93
- * **roi** (optional, heterogeneous) - **T2**:
60
+ * **roi** (heterogeneous) - **T2**:
94
61
  1-D tensor given as [start1, ..., startN, end1, ..., endN], where N
62
+ is the rank of X. The RoIs' coordinates are normalized in the
63
+ coordinate system of the input image. It only takes effect when
64
+ coordinate_transformation_mode is "tf_crop_and_resize"
95
- is the rank of X or the length of axes, if provided. The RoIs'
96
- coordinates are normalized in the coordinate system of the input
97
- image. It only takes effect when coordinate_transformation_mode is
98
- "tf_crop_and_resize"
99
- * **scales** (optional, heterogeneous) - **tensor(float)**:
65
+ * **scales** (heterogeneous) - **tensor(float)**:
100
66
  The scale array along each dimension. It takes value greater than 0.
101
67
  If it's less than 1, it's sampling down, otherwise, it's upsampling.
102
68
  The number of elements of 'scales' should be the same as the rank of
69
+ input 'X'. If 'size' is needed, the user must set 'scales' to an
70
+ empty tensor.
103
- input 'X' or the length of 'axes', if provided. One of 'scales' and
104
- 'sizes' MUST be specified and it is an error if both are specified.
105
- If 'sizes' is needed, the user can use an empty string as the name
106
- of 'scales' in this operator's input list.
107
71
  * **sizes** (optional, heterogeneous) - **tensor(int64)**:
72
+ The size of the output tensor. The number of elements of 'sizes'
108
- Target size of the output tensor. Its interpretation depends on the
109
- 'keep_aspect_ratio_policy' value.The number of elements of 'sizes'
110
- should be the same as the rank of input 'X', or the length of
73
+ should be the same as the rank of input 'X'. May only be set if
74
+ 'scales' is set to an empty tensor.
111
- 'axes', if provided. Only one of 'scales' and 'sizes' can be
112
- specified.
113
75
  **Outputs**
114
76
  * **Y** (heterogeneous) - **T1**:
115
77
  N-D tensor after resizing
116
78
  **Type Constraints**
117
79
  * **T1** in (
118
- tensor(bfloat16),
119
80
  tensor(bool),
120
81
  tensor(complex128),
121
82
  tensor(complex64),
122
83
  tensor(double),
123
84
  tensor(float),
124
85
  tensor(float16),
125
86
  tensor(int16),
126
87
  tensor(int32),
127
88
  tensor(int64),
128
89
  tensor(int8),
129
90
  tensor(string),
130
91
  tensor(uint16),
131
92
  tensor(uint32),
132
93
  tensor(uint64),
133
94
  tensor(uint8)
134
95
  ):
135
96
  Constrain input 'X' and output 'Y' to all tensor types.
136
97
  * **T2** in (
137
98
  tensor(double),
138
99
  tensor(float),
139
100
  tensor(float16)
140
101
  ):
141
102
  Constrain roi type to float or double.