Pad - 1 vs 11

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 → Pad11 +76 -22
Pad1 → Pad11 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)
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):
3
- Insert 0 paddings to the beginning of the second dimension.
13
+ Insert 0 pads to the beginning of the second dimension.
14
+
4
- data = [
15
+ data =
16
+ [
5
17
  [1.0, 1.2],
6
18
  [2.3, 3.4],
7
19
  [4.5, 5.7],
8
20
  ]
21
+
9
- paddings = [0, 0, 2, 0]
22
+ pads = [0, 2, 0, 0]
23
+
24
+ mode = 'constant'
25
+
26
+ constant_value = 0.0
27
+
10
- output = [
28
+ output =
11
- [
29
+ [
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
- ],
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],
16
71
  ]
17
72
  ### Attributes
18
73
  * **mode - STRING** (default is 'constant'):
19
- Three modes: constant(default), reflect, edge
74
+ 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
75
  ### Inputs
76
+
77
+ Between 2 and 3 inputs.
29
78
  - **data** (heterogeneous) - **T**:
30
79
  Input tensor.
80
+ - **pads** (heterogeneous) - **tensor(int64)**:
81
+
82
+ 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.
83
+ - **constant_value** (optional, heterogeneous) - **T**:
84
+
85
+ (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0).
31
86
  ### Outputs
32
87
  - **output** (heterogeneous) - **T**:
33
88
  Tensor after padding.
34
89
  ### Type Constraints
35
- * **T** in ( tensor(double), tensor(float), tensor(float16) ):
90
+ * **T** in ( tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ):
36
- Constrain input and output types to float tensors.+ Constrain input and output to only numeric types.