Pad - 13 vs 21

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. Pad13 → Pad21 +82 -49
Pad13 → Pad21 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
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
+ 4) wrap - wrap-around padding as if the data tensor forms a torus
8
+
7
9
  Example 1 (constant mode):
8
- Insert 0 pads to the beginning of the second dimension.
10
+ Insert 0 pads to the beginning of the second dimension.
9
- data =
11
+ data = [
10
- [
11
- [1.0, 1.2],
12
+ [1.0, 1.2],
12
- [2.3, 3.4],
13
+ [2.3, 3.4],
13
- [4.5, 5.7],
14
+ [4.5, 5.7],
14
- ]
15
+ ]
15
- pads = [0, 2, 0, 0]
16
- mode = 'constant'
16
+ pads = [0, 2, 0, 0]
17
+ mode = 'constant'
18
+
17
- constant_value = 0.0
19
+ constant_value = 0.0
20
+
18
- output =
21
+ output = [
19
- [
20
- [0.0, 0.0, 1.0, 1.2],
22
+ [0.0, 0.0, 1.0, 1.2],
21
- [0.0, 0.0, 2.3, 3.4],
23
+ [0.0, 0.0, 2.3, 3.4],
22
- [0.0, 0.0, 4.5, 5.7],
24
+ [0.0, 0.0, 4.5, 5.7],
23
- ]
25
+ ]
26
+
24
27
  Example 2 (reflect mode):
25
- data =
28
+ data = [
26
- [
27
- [1.0, 1.2],
29
+ [1.0, 1.2],
28
- [2.3, 3.4],
30
+ [2.3, 3.4],
29
- [4.5, 5.7],
31
+ [4.5, 5.7],
30
- ]
32
+ ]
31
- pads = [0, 2, 0, 0]
33
+ pads = [0, 2, 0, 0]
34
+
32
- mode = 'reflect'
35
+ mode = 'reflect'
36
+
33
- output =
37
+ output = [
34
- [
35
- [1.0, 1.2, 1.0, 1.2],
38
+ [1.0, 1.2, 1.0, 1.2],
36
- [2.3, 3.4, 2.3, 3.4],
39
+ [2.3, 3.4, 2.3, 3.4],
37
- [4.5, 5.7, 4.5, 5.7],
40
+ [4.5, 5.7, 4.5, 5.7],
38
- ]
41
+ ]
42
+
39
43
  Example 3 (edge mode):
40
- data =
44
+ data = [
41
- [
42
- [1.0, 1.2],
45
+ [1.0, 1.2],
43
- [2.3, 3.4],
46
+ [2.3, 3.4],
44
- [4.5, 5.7],
47
+ [4.5, 5.7],
45
- ]
48
+ ]
46
- pads = [0, 2, 0, 0]
49
+ pads = [0, 2, 0, 0]
50
+
47
- mode = 'edge'
51
+ mode = 'edge'
52
+
48
- output =
53
+ output = [
49
- [
50
- [1.0, 1.0, 1.0, 1.2],
54
+ [1.0, 1.0, 1.0, 1.2],
51
- [2.3, 2.3, 2.3, 3.4],
55
+ [2.3, 2.3, 2.3, 3.4],
52
- [4.5, 4.5, 4.5, 5.7],
56
+ [4.5, 4.5, 4.5, 5.7],
53
- ]
57
+ ]
58
+
59
+
60
+ Example 4 (wrap mode):
61
+
62
+
63
+ data = [
64
+ [1.0, 1.2],
65
+ [2.3, 3.4],
66
+ [4.5, 5.7],
67
+ ]
68
+
69
+ pads = [2, 1, 1, 1]
70
+
71
+ mode = 'wrap'
72
+
73
+ output = [
74
+ [3.4, 2.3, 3.4, 2.3],
75
+ [5.7, 4.5, 5.7, 4.5],
76
+ [1.2, 1.0, 1.2, 1.0],
77
+ [3.4, 2.3, 3.4, 2.3],
78
+ [5.7, 4.5, 5.7, 4.5],
79
+ [1.2, 1.0, 1.2, 1.0],
80
+ ]
81
+
54
82
  ### Attributes
55
83
  * **mode - STRING** (default is 'constant'):
56
- Supported modes: constant(default), reflect, edge
84
+ Supported modes: constant(default), reflect, edge, wrap
57
85
  ### Inputs
58
- Between 2 and 3 inputs.
86
+ Between 2 and 4 inputs.
59
87
  - **data** (heterogeneous) - **T**:
60
88
  Input tensor.
61
89
  - **pads** (heterogeneous) - **tensor(int64)**:
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.
90
+ 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].
63
91
  - **constant_value** (optional, heterogeneous) - **T**:
64
92
  (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).
93
+ - **axes** (optional, heterogeneous) - **Tind**:
94
+
95
+ 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]).
65
96
  ### Outputs
66
97
  - **output** (heterogeneous) - **T**:
67
98
  Tensor after padding.
68
99
  ### Type Constraints
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) ):
100
+ * **T** in ( tensor(bfloat16), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8) ):
101
+ * **Tind** in ( tensor(int32), tensor(int64) ):
102
+
70
- Constrain input and output types to all tensor types.+ Constrain input and output types to all tensor types up to IRv10.
103
+ Constrain indices to integer types