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 +91 -27
Pad1 → Pad18 RENAMED
@@ -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,
1
- Given data tensor, paddings, mode, and 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
+
2
- Example:
12
+ Example 1 (constant mode):
13
+
3
- Insert 0 paddings to the beginning of the second dimension.
14
+ Insert 0 pads to the beginning of the second dimension.
15
+
16
+
4
- data = [
17
+ data = [
5
- [1.0, 1.2],
18
+ [1.0, 1.2],
6
- [2.3, 3.4],
19
+ [2.3, 3.4],
7
- [4.5, 5.7],
20
+ [4.5, 5.7],
8
- ]
21
+ ]
22
+
9
- paddings = [0, 0, 2, 0]
23
+ pads = [0, 2, 0, 0]
24
+
25
+ mode = 'constant'
26
+
27
+ constant_value = 0.0
28
+
10
- output = [
29
+ output = [
11
- [
12
- [0.0, 0.0, 1.0, 1.2],
30
+ [0.0, 0.0, 1.0, 1.2],
13
- [0.0, 0.0, 2.3, 3.4],
31
+ [0.0, 0.0, 2.3, 3.4],
14
- [0.0, 0.0, 4.5, 5.7],
32
+ [0.0, 0.0, 4.5, 5.7],
15
- ],
16
- ]
33
+ ]
34
+
35
+
36
+ Example 2 (reflect mode):
37
+
38
+
39
+ data = [
40
+ [1.0, 1.2],
41
+ [2.3, 3.4],
42
+ [4.5, 5.7],
43
+ ]
44
+
45
+ pads = [0, 2, 0, 0]
46
+
47
+ mode = 'reflect'
48
+
49
+ output = [
50
+ [1.0, 1.2, 1.0, 1.2],
51
+ [2.3, 3.4, 2.3, 3.4],
52
+ [4.5, 5.7, 4.5, 5.7],
53
+ ]
54
+
55
+
56
+ Example 3 (edge mode):
57
+
58
+
59
+ data = [
60
+ [1.0, 1.2],
61
+ [2.3, 3.4],
62
+ [4.5, 5.7],
63
+ ]
64
+
65
+ pads = [0, 2, 0, 0]
66
+
67
+ mode = 'edge'
68
+
69
+ output = [
70
+ [1.0, 1.0, 1.0, 1.2],
71
+ [2.3, 2.3, 2.3, 3.4],
72
+ [4.5, 4.5, 4.5, 5.7],
73
+ ]
74
+
17
75
  ### Attributes
18
76
  * **mode - STRING** (default is 'constant'):
19
- Three modes: constant(default), reflect, edge
77
+ Supported modes: constant(default), reflect, edge
20
-
21
- * **paddings - INTS** (required) :
22
-
23
- List of integers indicate the padding element count at the beginning and end of each axis, for 2D it is the number of pixel. paddings rank should be double of the input's rank. paddings format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis i and xi_end, the number of pixels added at the end of axis i.
24
-
25
- * **value - FLOAT** (default is '0.0'):
26
-
27
- One float, indicates the value to be filled, default is 0
28
78
  ### Inputs
79
+
80
+ Between 2 and 4 inputs.
29
81
  - **data** (heterogeneous) - **T**:
30
82
  Input tensor.
83
+ - **pads** (heterogeneous) - **tensor(int64)**:
84
+
85
+ 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 * num_axes] where num_axes refers to the number of elements in the axes input or the input rank if axes are not provided explicitly. 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 axes[i] and xi_end, the number of pad values added at the end of axis axes[i].
86
+ - **constant_value** (optional, heterogeneous) - **T**:
87
+
88
+ (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).
89
+ - **axes** (optional, heterogeneous) - **Tind**:
90
+
91
+ 1-D tensor of axes that pads apply to. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an axis is repeated. If not provided, all axes are assumed ([0, 1, ..., input_rank-1]).
31
92
  ### Outputs
32
93
  - **output** (heterogeneous) - **T**:
33
94
  Tensor after padding.
34
95
  ### Type Constraints
35
- * **T** in ( tensor(double), tensor(float), tensor(float16) ):
96
+ * **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) ):
36
- Constrain input and output types to float tensors.? ^ ^^^
97
+ Constrain input and output types to all tensor types.
98
+ * **Tind** in ( tensor(int32), tensor(int64) ):
99
+
100
+ Constrain indices to integer types