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 +4 -4
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, empty string, or False)
|
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 - STRING** (default is 'constant'):
|
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 or remove (if negative) at the beginning and end of each axis. For 2D input tensor, it is the number of pixels. pads should be a 1D tensor of shape [2 * input_rank]. pads format should be: [x1_begin, x2_begin,...,x1_end, x2_end,...], where xi_begin is the number of pad values added at the beginning of axis i and xi_end, the number of pad values added at the end of axis i.
|
63
63
|
- **constant_value** (optional, heterogeneous) - **T**:
|
64
|
-
(Optional) A scalar value to be used if the mode chosen is constant (by default it is 0).
|
64
|
+
(Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).
|
65
65
|
### Outputs
|
66
66
|
- **output** (heterogeneous) - **T**:
|
67
67
|
Tensor after padding.
|
68
68
|
### Type Constraints
|
69
|
-
* **T** in ( tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ):
|
69
|
+
* **T** in ( 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) ):
|
70
|
-
Constrain input and output to
|
70
|
+
Constrain input and output types to all tensor types.? ++++++ ++++++++
|