Pad#
Pad - 13#
Version
name: Pad (GitHub)
domain: main
since_version: 13
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 13.
Summary
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, a padded tensor (output) is generated.
The three supported modes are (similar to corresponding modes supported by numpy.pad):
constant`(default) - pads with a given constant value as specified by `constant_value (which defaults to 0, empty string, or False)
reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis
edge - pads with the edge values of array
- Example 1 (constant mode):
Insert 0 pads to the beginning of the second dimension.
data = [
[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],
]
pads = [0, 2, 0, 0]
mode = ‘constant’
constant_value = 0.0
output = [
[0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7],
]
- Example 2 (reflect mode):
data = [
[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],
]
pads = [0, 2, 0, 0]
mode = ‘reflect’
output = [
[1.0, 1.2, 1.0, 1.2], [2.3, 3.4, 2.3, 3.4], [4.5, 5.7, 4.5, 5.7],
]
- Example 3 (edge mode):
data = [
[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],
]
pads = [0, 2, 0, 0]
mode = ‘edge’
output = [
[1.0, 1.0, 1.0, 1.2], [2.3, 2.3, 2.3, 3.4], [4.5, 4.5, 4.5, 5.7],
]
Attributes
mode: Supported modes: constant`(default), `reflect, edge Default value is
'constant'
.
Inputs
Between 2 and 3 inputs.
data (heterogeneous) - T: Input tensor.
pads (heterogeneous) - tensor(int64): 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.
constant_value (optional, heterogeneous) - T: (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0, empty string or False).
Outputs
output (heterogeneous) - T: Tensor after padding.
Type Constraints
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) ): Constrain input and output types to all tensor types.
Examples
constant_pad
node = onnx.helper.make_node(
'Pad',
inputs=['x', 'pads', 'value'],
outputs=['y'],
mode='constant'
)
x = np.random.randn(1, 3, 4, 5).astype(np.float32)
pads = np.array([0, 0, 1, 3, 0, 0, 2, 4]).astype(np.int64) # pad order [x1_begin, x2_begin, ..., x1_end, x2_end, ...]
value = np.float32(1.2)
y = pad_impl(
x,
pads,
'constant',
1.2
)
expect(node, inputs=[x, pads, value], outputs=[y],
name='test_constant_pad')
reflection_and_edge_pad
for mode in ['edge', 'reflect']:
node = onnx.helper.make_node(
'Pad',
inputs=['x', 'pads'],
outputs=['y'],
mode=mode
)
x = np.random.randn(1, 3, 4, 5).astype(np.int32)
pads = np.array([0, 0, 1, 1, 0, 0, 1, 1]).astype(np.int64) # pad order [x1_begin, x2_begin, ..., x1_end, x2_end, ...]
y = pad_impl(
x,
pads,
mode
)
expect(node, inputs=[x, pads], outputs=[y],
name='test_{}_pad'.format(mode))
Differences
0 | 0 | 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, | 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 | 1 | a padded tensor (output) is generated. | a padded tensor (output) is generated. |
2 | 2 |
|
|
3 | 3 | The three supported modes are (similar to corresponding modes supported by numpy.pad): | The three supported modes are (similar to corresponding modes supported by numpy.pad): |
4 | 4 |
|
|
5 | 5 | 1) constant(default) - pads with a given constant value as specified by constant_value (which defaults to 0) |
|
6 | 6 |
|
|
7 | 7 | 2) reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis | 2) reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis |
8 | 8 |
|
|
9 | 9 | 3) edge - pads with the edge values of array | 3) edge - pads with the edge values of array |
10 | 10 |
|
|
11 | 11 | Example 1 (constant mode): | Example 1 (constant mode): |
12 | 12 | Insert 0 pads to the beginning of the second dimension. | Insert 0 pads to the beginning of the second dimension. |
13 | 13 |
|
|
14 | 14 | data = | data = |
15 | 15 | [ | [ |
16 | 16 | [1.0, 1.2], | [1.0, 1.2], |
17 | 17 | [2.3, 3.4], | [2.3, 3.4], |
18 | 18 | [4.5, 5.7], | [4.5, 5.7], |
19 | 19 | ] | ] |
20 | 20 |
|
|
21 | 21 | pads = [0, 2, 0, 0] | pads = [0, 2, 0, 0] |
22 | 22 |
|
|
23 | 23 | mode = 'constant' | mode = 'constant' |
24 | 24 |
|
|
25 | 25 | constant_value = 0.0 | constant_value = 0.0 |
26 | 26 |
|
|
27 | 27 | output = | output = |
28 | 28 | [ | [ |
29 | 29 | [0.0, 0.0, 1.0, 1.2], | [0.0, 0.0, 1.0, 1.2], |
30 | 30 | [0.0, 0.0, 2.3, 3.4], | [0.0, 0.0, 2.3, 3.4], |
31 | 31 | [0.0, 0.0, 4.5, 5.7], | [0.0, 0.0, 4.5, 5.7], |
32 | 32 | ] | ] |
33 | 33 |
|
|
34 | 34 | Example 2 (reflect mode): | Example 2 (reflect mode): |
35 | 35 | data = | data = |
36 | 36 | [ | [ |
37 | 37 | [1.0, 1.2], | [1.0, 1.2], |
38 | 38 | [2.3, 3.4], | [2.3, 3.4], |
39 | 39 | [4.5, 5.7], | [4.5, 5.7], |
40 | 40 | ] | ] |
41 | 41 |
|
|
42 | 42 | pads = [0, 2, 0, 0] | pads = [0, 2, 0, 0] |
43 | 43 |
|
|
44 | 44 | mode = 'reflect' | mode = 'reflect' |
45 | 45 |
|
|
46 | 46 | output = | output = |
47 | 47 | [ | [ |
48 | 48 | [1.0, 1.2, 1.0, 1.2], | [1.0, 1.2, 1.0, 1.2], |
49 | 49 | [2.3, 3.4, 2.3, 3.4], | [2.3, 3.4, 2.3, 3.4], |
50 | 50 | [4.5, 5.7, 4.5, 5.7], | [4.5, 5.7, 4.5, 5.7], |
51 | 51 | ] | ] |
52 | 52 |
|
|
53 | 53 | Example 3 (edge mode): | Example 3 (edge mode): |
54 | 54 | data = | data = |
55 | 55 | [ | [ |
56 | 56 | [1.0, 1.2], | [1.0, 1.2], |
57 | 57 | [2.3, 3.4], | [2.3, 3.4], |
58 | 58 | [4.5, 5.7], | [4.5, 5.7], |
59 | 59 | ] | ] |
60 | 60 |
|
|
61 | 61 | pads = [0, 2, 0, 0] | pads = [0, 2, 0, 0] |
62 | 62 |
|
|
63 | 63 | mode = 'edge' | mode = 'edge' |
64 | 64 |
|
|
65 | 65 | output = | output = |
66 | 66 | [ | [ |
67 | 67 | [1.0, 1.0, 1.0, 1.2], | [1.0, 1.0, 1.0, 1.2], |
68 | 68 | [2.3, 2.3, 2.3, 3.4], | [2.3, 2.3, 2.3, 3.4], |
69 | 69 | [4.5, 4.5, 4.5, 5.7], | [4.5, 4.5, 4.5, 5.7], |
70 | 70 | ] | ] |
71 | 71 |
|
|
72 | 72 | **Attributes** | **Attributes** |
73 | 73 |
|
|
74 | 74 | * **mode**: | * **mode**: |
75 | 75 | Supported modes: constant(default), reflect, edge Default value is 'constant'. | Supported modes: constant(default), reflect, edge Default value is 'constant'. |
76 | 76 |
|
|
77 | 77 | **Inputs** | **Inputs** |
78 | 78 |
|
|
79 | 79 | Between 2 and 3 inputs. | Between 2 and 3 inputs. |
80 | 80 |
|
|
81 | 81 | * **data** (heterogeneous) - **T**: | * **data** (heterogeneous) - **T**: |
82 | 82 | Input tensor. | Input tensor. |
83 | 83 | * **pads** (heterogeneous) - **tensor(int64)**: | * **pads** (heterogeneous) - **tensor(int64)**: |
84 | 84 | Tensor of integers indicating the number of padding elements to add | Tensor of integers indicating the number of padding elements to add |
85 | 85 | or remove (if negative) at the beginning and end of each axis. For | or remove (if negative) at the beginning and end of each axis. For |
86 | 86 | 2D input tensor, it is the number of pixels. pads should be a 1D | 2D input tensor, it is the number of pixels. pads should be a 1D |
87 | 87 | tensor of shape [2 * input_rank]. pads format should be: | tensor of shape [2 * input_rank]. pads format should be: |
88 | 88 | [x1_begin, x2_begin,...,x1_end, x2_end,...], where xi_begin is the | [x1_begin, x2_begin,...,x1_end, x2_end,...], where xi_begin is the |
89 | 89 | number of pad values added at the beginning of axis i and xi_end, | number of pad values added at the beginning of axis i and xi_end, |
90 | 90 | the number of pad values added at the end of axis i. | the number of pad values added at the end of axis i. |
91 | 91 | * **constant_value** (optional, heterogeneous) - **T**: | * **constant_value** (optional, heterogeneous) - **T**: |
92 | 92 | (Optional) A scalar value to be used if the mode chosen is | (Optional) A scalar value to be used if the mode chosen is |
93 | 93 | constant (by default it is 0). |
|
94 | 94 |
|
|
95 | 95 | **Outputs** | **Outputs** |
96 | 96 |
|
|
97 | 97 | * **output** (heterogeneous) - **T**: | * **output** (heterogeneous) - **T**: |
98 | 98 | Tensor after padding. | Tensor after padding. |
99 | 99 |
|
|
100 | 100 | **Type Constraints** | **Type Constraints** |
101 | 101 |
|
|
102 | 102 | * **T** in ( | * **T** in ( |
103 | tensor(bfloat16), | ||
104 | tensor(bool), | ||
105 | tensor(complex128), | ||
106 | tensor(complex64), | ||
103 | 107 | tensor(double), | tensor(double), |
104 | 108 | tensor(float), | tensor(float), |
105 | 109 | tensor(float16), | tensor(float16), |
106 | 110 | tensor(int16), | tensor(int16), |
107 | 111 | tensor(int32), | tensor(int32), |
108 | 112 | tensor(int64), | tensor(int64), |
109 | 113 | tensor(int8), | tensor(int8), |
114 | tensor(string), | ||
110 | 115 | tensor(uint16), | tensor(uint16), |
111 | 116 | tensor(uint32), | tensor(uint32), |
112 | 117 | tensor(uint64), | tensor(uint64), |
113 | 118 | tensor(uint8) | tensor(uint8) |
114 | 119 | ): | ): |
115 | 120 | Constrains input and output to only numeric types. |
|
Pad - 11#
Version
name: Pad (GitHub)
domain: main
since_version: 11
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 11.
Summary
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, a padded tensor (output) is generated.
The three supported modes are (similar to corresponding modes supported by numpy.pad):
constant`(default) - pads with a given constant value as specified by `constant_value (which defaults to 0)
reflect - pads with the reflection of the vector mirrored on the first and last values of the vector along each axis
edge - pads with the edge values of array
- Example 1 (constant mode):
Insert 0 pads to the beginning of the second dimension.
data = [
[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],
]
pads = [0, 2, 0, 0]
mode = ‘constant’
constant_value = 0.0
output = [
[0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7],
]
- Example 2 (reflect mode):
data = [
[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],
]
pads = [0, 2, 0, 0]
mode = ‘reflect’
output = [
[1.0, 1.2, 1.0, 1.2], [2.3, 3.4, 2.3, 3.4], [4.5, 5.7, 4.5, 5.7],
]
- Example 3 (edge mode):
data = [
[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],
]
pads = [0, 2, 0, 0]
mode = ‘edge’
output = [
[1.0, 1.0, 1.0, 1.2], [2.3, 2.3, 2.3, 3.4], [4.5, 4.5, 4.5, 5.7],
]
Attributes
mode: Supported modes: constant`(default), `reflect, edge Default value is
'constant'
.
Inputs
Between 2 and 3 inputs.
data (heterogeneous) - T: Input tensor.
pads (heterogeneous) - tensor(int64): 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.
constant_value (optional, heterogeneous) - T: (Optional) A scalar value to be used if the mode chosen is constant (by default it is 0).
Outputs
output (heterogeneous) - T: Tensor after padding.
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrains input and output to only numeric types.
Differences
0 | 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 | a padded tensor (output) is generated. | ||
2 |
| ||
0 | 3 | Given data tensor, pads, mode, and value. |
|
1 | Example: | ||
4 |
| ||
5 | 1) constant(default) - pads with a given constant value as specified by constant_value (which defaults to 0) | ||
6 |
| ||
2 | 7 | Insert 0 pads to the beginning of the second dimension. |
|
3 | data = [ | ||
8 |
| ||
4 | 9 | [1.0, 1.2], |
|
10 |
| ||
5 | 11 | [2.3, 3.4], |
|
6 | 12 | [4.5, 5.7], |
|
13 |
| ||
14 | data = | ||
15 | [ | ||
16 | [1.0, 1.2], | ||
17 | [2.3, 3.4], | ||
18 | [4.5, 5.7], | ||
7 | 19 | ] | ] |
20 |
| ||
8 | 21 | pads = [0, 2, 0, 0] | pads = [0, 2, 0, 0] |
22 |
| ||
23 | mode = 'constant' | ||
24 |
| ||
25 | constant_value = 0.0 | ||
26 |
| ||
9 | 27 | output = [ |
|
10 | [ | ||
28 | [ | ||
11 | 29 | [0.0, 0.0, 1.0, 1.2], |
|
12 | 30 | [0.0, 0.0, 2.3, 3.4], |
|
13 | 31 | [0.0, 0.0, 4.5, 5.7], |
|
14 | ], | ||
15 | 32 | ] | ] |
16 | 33 |
|
|
34 | Example 2 (reflect mode): | ||
35 | data = | ||
36 | [ | ||
37 | [1.0, 1.2], | ||
38 | [2.3, 3.4], | ||
39 | [4.5, 5.7], | ||
40 | ] | ||
41 |
| ||
42 | pads = [0, 2, 0, 0] | ||
43 |
| ||
44 | mode = 'reflect' | ||
45 |
| ||
46 | output = | ||
47 | [ | ||
48 | [1.0, 1.2, 1.0, 1.2], | ||
49 | [2.3, 3.4, 2.3, 3.4], | ||
50 | [4.5, 5.7, 4.5, 5.7], | ||
51 | ] | ||
52 |
| ||
53 | Example 3 (edge mode): | ||
54 | data = | ||
55 | [ | ||
56 | [1.0, 1.2], | ||
57 | [2.3, 3.4], | ||
58 | [4.5, 5.7], | ||
59 | ] | ||
60 |
| ||
61 | pads = [0, 2, 0, 0] | ||
62 |
| ||
63 | mode = 'edge' | ||
64 |
| ||
65 | output = | ||
66 | [ | ||
67 | [1.0, 1.0, 1.0, 1.2], | ||
68 | [2.3, 2.3, 2.3, 3.4], | ||
69 | [4.5, 4.5, 4.5, 5.7], | ||
70 | ] | ||
71 |
| ||
17 | 72 | **Attributes** | **Attributes** |
18 | 73 |
|
|
19 | 74 | * **mode**: | * **mode**: |
20 | 75 | Three modes: constant(default), reflect, edge Default value is 'constant'. |
|
76 |
| ||
77 | **Inputs** | ||
78 |
| ||
79 | Between 2 and 3 inputs. | ||
80 |
| ||
81 | * **data** (heterogeneous) - **T**: | ||
82 | Input tensor. | ||
21 | 83 | * **pads** (required): |
|
22 | 84 | List of integers indicating the number of padding elements to add or |
|
23 | 85 | remove (if negative) at the beginning and end of each axis. For 2D |
|
24 | 86 | it is the number of pixels. pads rank should be double of the |
|
25 | 87 | input's rank. pads format should be as follow [x1_begin, |
|
26 | 88 | x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels |
|
27 | 89 | added at the beginning of axis i and xi_end, the number of pixels |
|
28 | 90 | added at the end of axis i. |
|
29 | 91 | * **value**: |
|
92 | (Optional) A scalar value to be used if the mode chosen is | ||
30 | 93 | One float, indicates the value to be filled. Default value is 0.0. |
|
31 | 94 |
|
|
32 | **Inputs** | ||
33 |
| ||
34 | * **data** (heterogeneous) - **T**: | ||
35 | Input tensor. | ||
36 |
| ||
37 | 95 | **Outputs** | **Outputs** |
38 | 96 |
|
|
39 | 97 | * **output** (heterogeneous) - **T**: | * **output** (heterogeneous) - **T**: |
40 | 98 | Tensor after padding. | Tensor after padding. |
41 | 99 |
|
|
42 | 100 | **Type Constraints** | **Type Constraints** |
43 | 101 |
|
|
44 | 102 | * **T** in ( | * **T** in ( |
45 | 103 | tensor(double), | tensor(double), |
46 | 104 | tensor(float), | tensor(float), |
47 | 105 | tensor(float16) |
|
106 | tensor(int16), | ||
107 | tensor(int32), | ||
108 | tensor(int64), | ||
109 | tensor(int8), | ||
110 | tensor(uint16), | ||
111 | tensor(uint32), | ||
112 | tensor(uint64), | ||
113 | tensor(uint8) | ||
48 | 114 | ): | ): |
49 | 115 | Constrain input and output types to float tensors. |
|
Pad - 2#
Version
name: Pad (GitHub)
domain: main
since_version: 2
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 2.
Summary
Given data tensor, pads, mode, and value. Example:
Insert 0 pads to the beginning of the second dimension. data = [
[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],
] pads = [0, 2, 0, 0] output = [
- [
[0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7],
],
]
Attributes
mode: Three modes: constant(default), reflect, edge Default value is
'constant'
.pads (required): List of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D it is the number of pixels. pads rank should be double of the input’s rank. pads 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.
value: One float, indicates the value to be filled. Default value is
0.0
.
Inputs
data (heterogeneous) - T: Input tensor.
Outputs
output (heterogeneous) - T: Tensor after padding.
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.
Differences
0 | 0 | Given data tensor, paddings, mode, and value. |
|
1 | 1 | Example: | Example: |
2 | 2 | Insert 0 paddings to the beginning of the second dimension. |
|
3 | 3 | data = [ | data = [ |
4 | 4 | [1.0, 1.2], | [1.0, 1.2], |
5 | 5 | [2.3, 3.4], | [2.3, 3.4], |
6 | 6 | [4.5, 5.7], | [4.5, 5.7], |
7 | 7 | ] | ] |
8 | 8 | paddings = [0, 0, 2, 0] |
|
9 | 9 | output = [ | output = [ |
10 | 10 | [ | [ |
11 | 11 | [0.0, 0.0, 1.0, 1.2], | [0.0, 0.0, 1.0, 1.2], |
12 | 12 | [0.0, 0.0, 2.3, 3.4], | [0.0, 0.0, 2.3, 3.4], |
13 | 13 | [0.0, 0.0, 4.5, 5.7], | [0.0, 0.0, 4.5, 5.7], |
14 | 14 | ], | ], |
15 | 15 | ] | ] |
16 | 16 |
|
|
17 | 17 | **Attributes** | **Attributes** |
18 | 18 |
|
|
19 | 19 | * **mode**: | * **mode**: |
20 | 20 | Three modes: constant(default), reflect, edge Default value is 'constant'. | Three modes: constant(default), reflect, edge Default value is 'constant'. |
21 | 21 | * **paddings** (required): |
|
22 | 22 | List of integers indicate the padding element count at the beginning |
|
23 | remove (if negative) at the beginning and end of each axis. For 2D | ||
23 | 24 | and end of each axis, for 2D it is the number of pixel. paddings |
|
24 | 25 | rank should be double of the input's rank. paddings format should |
|
25 | 26 | be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where |
|
26 | 27 | xi_begin the number of pixels added at the beginning of axis i and |
|
27 | 28 | xi_end, the number of pixels added at the end of axis i. |
|
28 | 29 | * **value**: | * **value**: |
29 | 30 | One float, indicates the value to be filled, default is 0 Default value is 0.0. |
|
30 | 31 |
|
|
31 | 32 | **Inputs** | **Inputs** |
32 | 33 |
|
|
33 | 34 | * **data** (heterogeneous) - **T**: | * **data** (heterogeneous) - **T**: |
34 | 35 | Input tensor. | Input tensor. |
35 | 36 |
|
|
36 | 37 | **Outputs** | **Outputs** |
37 | 38 |
|
|
38 | 39 | * **output** (heterogeneous) - **T**: | * **output** (heterogeneous) - **T**: |
39 | 40 | Tensor after padding. | Tensor after padding. |
40 | 41 |
|
|
41 | 42 | **Type Constraints** | **Type Constraints** |
42 | 43 |
|
|
43 | 44 | * **T** in ( | * **T** in ( |
44 | 45 | tensor(double), | tensor(double), |
45 | 46 | tensor(float), | tensor(float), |
46 | 47 | tensor(float16) | tensor(float16) |
47 | 48 | ): | ): |
48 | 49 | Constrain input and output types to float tensors. | Constrain input and output types to float tensors. |
Pad - 1#
Version
name: Pad (GitHub)
domain: main
since_version: 1
function: False
support_level: SupportType.COMMON
shape inference: False
This version of the operator has been available since version 1.
Summary
Given data tensor, paddings, mode, and value. Example:
Insert 0 paddings to the beginning of the second dimension. data = [
[1.0, 1.2], [2.3, 3.4], [4.5, 5.7],
] paddings = [0, 0, 2, 0] output = [
- [
[0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7],
],
]
Attributes
mode: Three modes: constant(default), reflect, edge Default value is
'constant'
.paddings (required): 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.
value: One float, indicates the value to be filled, default is 0 Default value is
0.0
.
Inputs
data (heterogeneous) - T: Input tensor.
Outputs
output (heterogeneous) - T: Tensor after padding.
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.