FilesLast commitLast update
18 days ago
2 months ago
2 months ago
6 days ago
20 days ago
5 days ago
5 days ago
18 days ago
5 days ago
1 month ago
12 days ago
README

PadV3

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.

  • Example:

    Input tensor([[0,1,2]])
    paddings([2,2])
    
    1.mode("REFLECT")
    The output is ([[2,1,0,1,2,1,0]])
    
    2.mode("SYMMETRIC")
    The output is ([[1,0,0,1,2,2,1]])
    
    3.mode("constant")
    The output is ([[0,0,0,1,2,0,0]])
    
    4.mode("edge")
    The output is ([[0,0,0,1,2,2,2]])
    

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input Original tensor to be expanded. FLOAT, FLOAT16, INT32, INT64, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, COMPLEX64, COMPLEX128, BFLOAT16, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, FLOAT4_E1M2. ND
paddings Input Configuration of the expansion. INT32, INT64 ND
constant_values Input Value of the padding constant in constant mode. FLOAT, FLOAT16, INT32, INT64, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, COMPLEX64, COMPLEX128, BFLOAT16, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, FLOAT4_E1M2. ND
mode Attribute Padding mode. There are four options: constant "constant", edge "edge", reflection "REFLECT", and symmetry "SYMMETRIC". string ND
paddings_contiguous Attribute Controls whether the storage of the paddings tensor is "contiguous". bool ND
y Output Tensor after expansion. FLOAT, FLOAT16, INT32, INT64, INT16, INT8, UINT8, UINT16, UINT32, UINT64, BOOL, DOUBLE, COMPLEX64, COMPLEX128, 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.

  • paddings Dimension 0 of paddings indicates the expansion configuration for dimension 0 of input x, and so on. Each row indicates the number of paddings in the corresponding dimension (left/right, front/back, top/bottom, and so on). For each row [a, b], a indicates the number of elements padded at the beginning of the dimension, and b indicates the number of elements padded at the end of the dimension (when paddings_contiguous is true).

  • mode In constant mode, the tensor is padded with a constant value. The constant value is indicated in the input constant_values, and an empty constant_values indicates padding with 0. In edge mode, the tensor is padded with the edge values of input x. In REFLECT mode, the tensor is padded in a mirrored manner, and the boundary itself is not included during mirroring. In SYMMETRIC mode, the tensor is padded in a mirrored manner, and the boundary itself is included during mirroring.

  • paddings_contiguous

    If it is true, paddings is arranged in row-major order. For example, [[2,2],[1,1]] indicates:

      Dimension 0: 2 is padded on the left and 2 on the right.
      Dimension 1: 1 is padded on the left and 1 on the right.
    

    If it is false, paddings is arranged in column-major order. For example, [[2,1],[2,1]] indicates:

      Dimension 0: 2 is padded on the left and 2 on the right.
      Dimension 1: 1 is padded on the left and 1 on the right.
    

Constraint Description

In the case of paddings_contiguous = true, that is, row-major order: The shape of paddings must be [rank, 2], where rank is the number of dimensions of input x. For each row paddings[i], the number of padded elements cannot exceed the number of elements of the corresponding x[i]. That is, in REFLECT mode, paddings[i][0] and paddings[i][1] <= x[i].length-1; in SYMMETRIC mode, paddings[i][0] and paddings[i][1] <= x[i].length.

In the case of paddings_contiguous = false, that is, column-major order, the paddings constraints of REFLECT mode and SYMMETRIC mode are the same by analogy.

In CONSTANT mode, if the data type of x is HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0, FLOAT4_E2M1, or FLOAT4_E1M2, all dimensions of paddings must be non-negative numbers; if the data type of x is FLOAT4_E2M1 or FLOAT4_E1M2, the paddings of the last dimension of input x must also be even numbers.

Invocation Description

Invocation Method Invocation Sample Description
aclnn invocation test_aclnn_constant_pad_nd Invokes the pad_v3 operator in constant mode through the aclnnConstantPadNd API.
aclnn invocation test_aclnn_replication_pad_1d Invokes the pad_v3 operator in edge mode through the aclnnReplicationPad1d API, and pads the last dimension of the input tensor.
aclnn invocation test_aclnn_replication_pad_2d Invokes the pad_v3 operator in edge mode through the aclnnReplicationPad2d API, and pads the last two dimensions of the input tensor.
aclnn invocation test_aclnn_replication_pad_3d Invokes the pad_v3 operator in edge mode through the aclnnReplicationPad3d API, and pads the last three dimensions of the input tensor.