Pad - 11 vs 13#
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.
- Pad11 → Pad13 +3 -8
Pad11 → Pad13
RENAMED
@@ -1 +1 @@
|
|
1
1
|
Given a tensor containing the data to be padded (data), a tensor containing the number of start and end pad values for axis (pads), (optionally) a mode, and (optionally) constant_value,
|
2
2
|
a padded tensor (output) is generated.
|
3
3
|
The three supported modes are (similar to corresponding modes supported by numpy.pad):
|
4
|
-
1) constant(default) - pads with a given constant value as specified by constant_value (which defaults to 0
|
4
|
+
1) constant(default) - pads with a given constant value as specified by constant_value (which defaults to 0)
|
5
5
|
2) reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis
|
6
6
|
3) edge - pads with the edge values of array
|
7
7
|
Example 1 (constant mode):
|
8
8
|
Insert 0 pads to the beginning of the second dimension.
|
9
9
|
data =
|
10
10
|
[
|
11
11
|
[1.0, 1.2],
|
12
12
|
[2.3, 3.4],
|
13
13
|
[4.5, 5.7],
|
14
14
|
]
|
15
15
|
pads = [0, 2, 0, 0]
|
16
16
|
mode = 'constant'
|
17
17
|
constant_value = 0.0
|
18
18
|
output =
|
19
19
|
[
|
20
20
|
[0.0, 0.0, 1.0, 1.2],
|
21
21
|
[0.0, 0.0, 2.3, 3.4],
|
22
22
|
[0.0, 0.0, 4.5, 5.7],
|
23
23
|
]
|
24
24
|
Example 2 (reflect mode):
|
25
25
|
data =
|
26
26
|
[
|
27
27
|
[1.0, 1.2],
|
28
28
|
[2.3, 3.4],
|
29
29
|
[4.5, 5.7],
|
30
30
|
]
|
31
31
|
pads = [0, 2, 0, 0]
|
32
32
|
mode = 'reflect'
|
33
33
|
output =
|
34
34
|
[
|
35
35
|
[1.0, 1.2, 1.0, 1.2],
|
36
36
|
[2.3, 3.4, 2.3, 3.4],
|
37
37
|
[4.5, 5.7, 4.5, 5.7],
|
38
38
|
]
|
39
39
|
Example 3 (edge mode):
|
40
40
|
data =
|
41
41
|
[
|
42
42
|
[1.0, 1.2],
|
43
43
|
[2.3, 3.4],
|
44
44
|
[4.5, 5.7],
|
45
45
|
]
|
46
46
|
pads = [0, 2, 0, 0]
|
47
47
|
mode = 'edge'
|
48
48
|
output =
|
49
49
|
[
|
50
50
|
[1.0, 1.0, 1.0, 1.2],
|
51
51
|
[2.3, 2.3, 2.3, 3.4],
|
52
52
|
[4.5, 4.5, 4.5, 5.7],
|
53
53
|
]
|
54
54
|
**Attributes**
|
55
55
|
* **mode**:
|
56
56
|
Supported modes: constant(default), reflect, edge
|
57
57
|
**Inputs**
|
58
58
|
Between 2 and 3 inputs.
|
59
59
|
* **data** (heterogeneous) - **T**:
|
60
60
|
Input tensor.
|
61
61
|
* **pads** (heterogeneous) - **tensor(int64)**:
|
62
62
|
Tensor of integers indicating the number of padding elements to add
|
63
63
|
or remove (if negative) at the beginning and end of each axis. For
|
64
64
|
2D input tensor, it is the number of pixels. pads should be a 1D
|
65
65
|
tensor of shape [2 * input_rank]. pads format should be:
|
66
66
|
[x1_begin, x2_begin,...,x1_end, x2_end,...], where xi_begin is the
|
67
67
|
number of pad values added at the beginning of axis i and xi_end,
|
68
68
|
the number of pad values added at the end of axis i.
|
69
69
|
* **constant_value** (optional, heterogeneous) - **T**:
|
70
70
|
(Optional) A scalar value to be used if the mode chosen is
|
71
|
-
constant (by default it is 0
|
71
|
+
constant (by default it is 0).
|
72
72
|
**Outputs**
|
73
73
|
* **output** (heterogeneous) - **T**:
|
74
74
|
Tensor after padding.
|
75
75
|
**Type Constraints**
|
76
76
|
* **T** in (
|
77
|
-
tensor(bfloat16),
|
78
|
-
tensor(bool),
|
79
|
-
tensor(complex128),
|
80
|
-
tensor(complex64),
|
81
77
|
tensor(double),
|
82
78
|
tensor(float),
|
83
79
|
tensor(float16),
|
84
80
|
tensor(int16),
|
85
81
|
tensor(int32),
|
86
82
|
tensor(int64),
|
87
83
|
tensor(int8),
|
88
|
-
tensor(string),
|
89
84
|
tensor(uint16),
|
90
85
|
tensor(uint32),
|
91
86
|
tensor(uint64),
|
92
87
|
tensor(uint8)
|
93
88
|
):
|
94
|
-
Constrain input and output
|
89
|
+
Constrain input and output to only numeric types.? ^^ ^ ^^^ ++
|