| Files | Last commit | Last update |
|---|---|---|
| 10 days ago | ||
| 2 months ago | ||
| 13 days ago | ||
| 13 days ago | ||
| 1 month ago | ||
| 13 days ago | ||
| 19 days ago | ||
| 13 days ago | ||
| 5 days ago |
PadV2
English | 简体中文
Product Support Status
| Product | Supported |
|---|---|
| Ascend 950PR&950DT products | √ |
| Atlas A3 products | √ |
| Atlas A2 products | √ |
| Atlas 200I/500 A2 inference products | √ |
| Atlas inference products | √ |
| Atlas training products | √ |
Function Description
-
Operator function: pads the input tensor with a constant of a specified value.
-
Example:
Input tensor([[0,1,2]]) paddings([[0,0],[2,2]]) constant_values(0) The output is ([[0,0,0,1,2,0,0]])
Parameter Description
| Parameter Name | Input/Output/Attribute | Description | Data Type | Data Format |
|---|---|---|---|---|
| x | Input | Original tensor to be padded. | FLOAT, FLOAT16, INT32, INT64, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, BFLOAT16, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, FLOAT4_E1M2. | ND |
| paddings | Input | Padding configuration. shape=[N, 2], where N is the number of dimensions of x. | INT32, INT64 | ND |
| constant_values | Input | Padding constant value, which is a scalar tensor. | FLOAT, FLOAT16, INT32, INT64, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, BFLOAT16, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, FLOAT4_E1M2. | ND |
| y | Output | Tensor after padding. | FLOAT, FLOAT16, INT32, INT64, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, BFLOAT16, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, FLOAT4_E1M2. | ND |
- Atlas training products, Atlas inference products, and Atlas 200I/500 A2 inference products: the data types BFLOAT16, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, and FLOAT4_E1M2 are not supported.
- Atlas A3 products and Atlas A2 products: the data types HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, and FLOAT4_E1M2 are not supported.
Output Shape Computation
y.shape[d] = x.shape[d] + paddings[d][0] + paddings[d][1]
Constraint Description
-
Dimension constraints:
- The number of dimensions of x must be in the range [1, 8]
- The first dimension of paddings must be equal to the number of dimensions of x
- The second dimension of paddings must be equal to 2
-
Data type constraints:
- x, constant_values, and y must use the same data type
- paddings must use INT32 or INT64
-
fp8/fp4 type constraints:
- When x is HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, or FLOAT4_E1M2, each dimension of paddings must be a non-negative value
- When x is FLOAT4_E2M1 or FLOAT4_E1M2, the shape of the trailing axis of the input must be an even number, and the paddings of the trailing axis must be an even number
-
Padding constraints:
- For negative padding (slice), the output shape = x.shape[d] + left + right >= 0
-
paddings parameter constraints
- The shape of paddings must be [rank, 2], where rank is the number of dimensions of input x (1 to 8)
- Each row [left, right] indicates the number of paddings in the corresponding dimension
- left: the number of elements padded at the beginning of the dimension
- right: the number of elements padded at the end of the dimension
- The value of paddings can be:
- A positive number: indicates padding
- A negative number: indicates slice (cropping)
- Zero: indicates no padding
Invocation Description
| Invocation Method | Sample Code | Description |
|---|---|---|
| GE graph mode | test_geir_pad_v2.cpp | Invokes the PadV2 operator through the operator IR API |