Pad - 1 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. Pad1 → Pad18 +23 -107
Pad1 → Pad18 RENAMED
@@ -1 +1 @@
1
+ Given data tensor, paddings, mode, and value.
2
+ Example:
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
- a padded tensor (output) is generated.
3
-
4
- The three supported modes are (similar to corresponding modes supported by numpy.pad):
5
-
6
- 1) constant(default) - pads with a given constant value as specified by constant_value (which defaults to 0, empty string, or False)
7
-
8
- 2) reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis
9
-
10
- 3) edge - pads with the edge values of array
11
-
12
- Example 1 (constant mode):
13
- Insert 0 pads to the beginning of the second dimension.
3
+ Insert 0 paddings to the beginning of the second dimension.
14
-
15
- data =
4
+ data = [
16
- [
17
5
  [1.0, 1.2],
18
6
  [2.3, 3.4],
19
7
  [4.5, 5.7],
20
8
  ]
21
-
22
- pads = [0, 2, 0, 0]
9
+ paddings = [0, 0, 2, 0]
23
-
24
- mode = 'constant'
25
-
26
- constant_value = 0.0
27
-
28
- output =
10
+ output = [
29
- [
11
+ [
30
- [0.0, 0.0, 1.0, 1.2],
12
+ [0.0, 0.0, 1.0, 1.2],
31
- [0.0, 0.0, 2.3, 3.4],
13
+ [0.0, 0.0, 2.3, 3.4],
32
- [0.0, 0.0, 4.5, 5.7],
14
+ [0.0, 0.0, 4.5, 5.7],
15
+ ],
33
- ]
34
-
35
- Example 2 (reflect mode):
36
- data =
37
- [
38
- [1.0, 1.2],
39
- [2.3, 3.4],
40
- [4.5, 5.7],
41
- ]
42
-
43
- pads = [0, 2, 0, 0]
44
-
45
- mode = 'reflect'
46
-
47
- output =
48
- [
49
- [1.0, 1.2, 1.0, 1.2],
50
- [2.3, 3.4, 2.3, 3.4],
51
- [4.5, 5.7, 4.5, 5.7],
52
- ]
53
-
54
- Example 3 (edge mode):
55
- data =
56
- [
57
- [1.0, 1.2],
58
- [2.3, 3.4],
59
- [4.5, 5.7],
60
- ]
61
-
62
- pads = [0, 2, 0, 0]
63
-
64
- mode = 'edge'
65
-
66
- output =
67
- [
68
- [1.0, 1.0, 1.0, 1.2],
69
- [2.3, 2.3, 2.3, 3.4],
70
- [4.5, 4.5, 4.5, 5.7],
71
16
  ]
72
17
  **Attributes**
73
18
  * **mode**:
74
- Supported modes: constant(default), reflect, edge
19
+ Three modes: constant(default), reflect, edge
20
+ * **paddings** (required):
21
+ List of integers indicate the padding element count at the beginning
22
+ and end of each axis, for 2D it is the number of pixel. paddings
23
+ rank should be double of the input's rank. paddings format should
24
+ be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where
25
+ xi_begin the number of pixels added at the beginning of axis i and
26
+ xi_end, the number of pixels added at the end of axis i.
27
+ * **value**:
28
+ One float, indicates the value to be filled, default is 0
75
29
  **Inputs**
76
- Between 2 and 4 inputs.
77
-
78
30
  * **data** (heterogeneous) - **T**:
79
31
  Input tensor.
80
- * **pads** (heterogeneous) - **tensor(int64)**:
81
- Tensor of integers indicating the number of padding elements to add
82
- or remove (if negative) at the beginning and end of each axis. For
83
- 2D input tensor, it is the number of pixels. pads should be a 1D
84
- tensor of shape [2 * num_axes] where num_axes refers to the number
85
- of elements in the axes input or the input rank if axes are not
86
- provided explicitly. pads format should be: [x1_begin, x2_begin,
87
- ..., x1_end, x2_end,...], where xi_begin is the number of pad values
88
- added at the beginning of axis axes[i] and xi_end, the number of
89
- pad values added at the end of axis axes[i].
90
- * **constant_value** (optional, heterogeneous) - **T**:
91
- (Optional) A scalar value to be used if the mode chosen is
92
- constant (by default it is 0, empty string or False).
93
- * **axes** (optional, heterogeneous) - **Tind**:
94
- 1-D tensor of axes that pads apply to. Negative value means
95
- counting dimensions from the back. Accepted range is [-r, r-1] where
96
- r = rank(data). Behavior is undefined if an axis is repeated. If not
97
- provided, all axes are assumed ([0, 1, ..., input_rank-1]).
98
32
  **Outputs**
99
33
  * **output** (heterogeneous) - **T**:
100
34
  Tensor after padding.
101
35
  **Type Constraints**
102
36
  * **T** in (
103
- tensor(bfloat16),
104
- tensor(bool),
105
- tensor(complex128),
106
- tensor(complex64),
107
37
  tensor(double),
108
38
  tensor(float),
109
- tensor(float16),
39
+ tensor(float16)
110
- tensor(int16),
111
- tensor(int32),
112
- tensor(int64),
113
- tensor(int8),
114
- tensor(string),
115
- tensor(uint16),
116
- tensor(uint32),
117
- tensor(uint64),
118
- tensor(uint8)
119
40
  ):
120
- Constrain input and output types to all tensor types.
41
+ Constrain input and output types to float tensors.? +++ ^
121
- * **Tind** in (
122
- tensor(int32),
123
- tensor(int64)
124
- ):
125
- Constrain indices to integer types