Pad - 2 vs 11

Files changed (1) hide show
  1. Pad2 → Pad11 +87 -22
Pad2 → 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, pads, 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
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
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**:
19
- Three modes: constant(default), reflect, edge
74
+ Supported modes: constant(default), reflect, edge
20
- * **pads** (required):
21
- List of integers indicating the number of padding elements to add or
22
- remove (if negative) at the beginning and end of each axis. For 2D
23
- it is the number of pixels. pads rank should be double of the
24
- input's rank. pads format should be as follow [x1_begin,
25
- x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels
26
- added at the beginning of axis i and xi_end, the number of pixels
27
- added at the end of axis i.
28
- * **value**:
29
- One float, indicates the value to be filled.
30
75
  **Inputs**
76
+ Between 2 and 3 inputs.
77
+
31
78
  * **data** (heterogeneous) - **T**:
32
79
  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 * input_rank]. pads format should be:
85
+ [x1_begin, x2_begin,...,x1_end, x2_end,...], where xi_begin is the
86
+ number of pad values added at the beginning of axis i and xi_end,
87
+ the number of pad values added at the end of axis i.
88
+ * **constant_value** (optional, heterogeneous) - **T**:
89
+ (Optional) A scalar value to be used if the mode chosen is
90
+ constant (by default it is 0).
33
91
  **Outputs**
34
92
  * **output** (heterogeneous) - **T**:
35
93
  Tensor after padding.
36
94
  **Type Constraints**
37
95
  * **T** in (
38
96
  tensor(double),
39
97
  tensor(float),
40
- tensor(float16)
98
+ tensor(float16),
99
+ tensor(int16),
100
+ tensor(int32),
101
+ tensor(int64),
102
+ tensor(int8),
103
+ tensor(uint16),
104
+ tensor(uint32),
105
+ tensor(uint64),
106
+ tensor(uint8)
41
107
  ):
42
- Constrain input and output types to float tensors.+ Constrain input and output to only numeric types.