Resize - 13 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.
- Resize13 → Resize18 +38 -76
Resize13 → 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:
|
2
|
+
Each dimension value of the output tensor is:
|
3
|
-
output_dimension = floor(input_dimension * (roi_end - roi_start) * scale)
|
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
|
-
|
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 "
|
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
|
-
|
18
|
+
x_original = length_resized > 1 ? (x_resized + 0.5) / scale - 0.5 :
|
33
|
-
0
|
19
|
+
0, <br/> if coordinate_transformation_mode is "align_corners",
|
34
|
-
|
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
|
-
|
21
|
+
(length_resized - 1), <br/> if coordinate_transformation_mode is
|
38
|
-
"
|
22
|
+
"asymmetric", <br/> x_original = x_resized / scale, <br/> if
|
23
|
+
coordinate_transformation_mode is "tf_crop_and_resize", <br/>
|
39
|
-
|
24
|
+
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)
|
25
|
+
x_resized * (end_x - start_x) * (length_original - 1) /
|
26
|
+
(length_resized - 1) : 0.5 * (start_x + end_x) * (length_original -
|
27
|
+
1).
|
42
28
|
* **cubic_coeff_a**:
|
43
29
|
The coefficient 'a' used in cubic interpolation. Two common choice
|
44
30
|
are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check
|
45
31
|
out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for
|
46
|
-
the details. This attribute is valid only if mode is "cubic".
|
32
|
+
the details. This attribute is valid only if "mode" is "cubic".
|
47
33
|
* **exclude_outside**:
|
48
34
|
If set to 1, the weight of sampling locations outside the tensor
|
49
35
|
will be set to 0 and the weight will be renormalized so that their
|
50
36
|
sum is 1.0. The default value is 0.
|
51
37
|
* **extrapolation_value**:
|
52
38
|
When coordinate_transformation_mode is "tf_crop_and_resize" and
|
53
39
|
x_original is outside the range [0, length_original - 1], this value
|
54
40
|
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
41
|
* **mode**:
|
77
|
-
Three interpolation modes:
|
42
|
+
Three interpolation modes: nearest (default), linear and cubic. The
|
78
|
-
"
|
43
|
+
"linear" mode includes linear interpolation for 1D tensor and
|
79
|
-
|
44
|
+
N-linear interpolation for N-D tensor (for example, bilinear
|
80
|
-
|
45
|
+
interpolation for 2D tensor). The "cubic" mode includes cubic
|
81
|
-
|
46
|
+
interpolation for 1D tensor and N-cubic interpolation for N-D tensor
|
82
|
-
|
47
|
+
(for example, bicubic interpolation for 2D tensor).
|
83
48
|
* **nearest_mode**:
|
84
|
-
Four modes:
|
49
|
+
Four modes: round_prefer_floor (default, as known as round half
|
85
|
-
down),
|
50
|
+
down), round_prefer_ceil (as known as round half up), floor, ceil.
|
86
|
-
|
51
|
+
Only used by nearest interpolation. It indicates how to get
|
87
52
|
"nearest" pixel in input tensor from x_original, so this attribute
|
88
53
|
is valid only if "mode" is "nearest".
|
89
54
|
**Inputs**
|
90
55
|
Between 1 and 4 inputs.
|
91
56
|
* **X** (heterogeneous) - **T1**:
|
92
57
|
N-D tensor
|
93
58
|
* **roi** (optional, heterogeneous) - **T2**:
|
94
59
|
1-D tensor given as [start1, ..., startN, end1, ..., endN], where N
|
60
|
+
is the rank of X. The RoIs' coordinates are normalized in the
|
61
|
+
coordinate system of the input image. It only takes effect when
|
62
|
+
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
63
|
* **scales** (optional, heterogeneous) - **tensor(float)**:
|
100
64
|
The scale array along each dimension. It takes value greater than 0.
|
101
65
|
If it's less than 1, it's sampling down, otherwise, it's upsampling.
|
102
66
|
The number of elements of 'scales' should be the same as the rank of
|
103
|
-
input 'X'
|
67
|
+
input 'X'. One of 'scales' and 'sizes' MUST be specified and it is
|
104
|
-
|
68
|
+
an error if both are specified. If 'sizes' is needed, the user can
|
105
|
-
If 'sizes' is needed, the user can use an empty string as the name
|
106
|
-
of 'scales' in this operator's input
|
69
|
+
use an empty string as the name of 'scales' in this operator's input
|
70
|
+
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'
|
73
|
+
should be the same as the rank of input 'X'. Only one of 'scales'
|
74
|
+
and 'sizes' can be specified.
|
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
80
|
tensor(bfloat16),
|
119
81
|
tensor(bool),
|
120
82
|
tensor(complex128),
|
121
83
|
tensor(complex64),
|
122
84
|
tensor(double),
|
123
85
|
tensor(float),
|
124
86
|
tensor(float16),
|
125
87
|
tensor(int16),
|
126
88
|
tensor(int32),
|
127
89
|
tensor(int64),
|
128
90
|
tensor(int8),
|
129
91
|
tensor(string),
|
130
92
|
tensor(uint16),
|
131
93
|
tensor(uint32),
|
132
94
|
tensor(uint64),
|
133
95
|
tensor(uint8)
|
134
96
|
):
|
135
97
|
Constrain input 'X' and output 'Y' to all tensor types.
|
136
98
|
* **T2** in (
|
137
99
|
tensor(double),
|
138
100
|
tensor(float),
|
139
101
|
tensor(float16)
|
140
102
|
):
|
141
103
|
Constrain roi type to float or double.
|