FilesLast commitLast update
19 days ago
2 months ago
2 months ago
1 month ago
21 days ago
26 days ago
2 months ago
22 days ago
26 days ago
1 month ago
13 days ago
README

MirrorPad

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 boundaries of the input tensor in a mirrored manner.

  • 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]])
    

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input Original tensor to be mirrored and expanded. INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, BF16, FLOAT16, FLOAT, DOUBLE, BOOL, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0 ND
paddings Input Configuration of the expansion. INT32, INT64 ND
mode Attribute Padding mode, which can be reflection "REFLECT" or symmetry "SYMMETRIC". string ND
y Output Tensor after expansion. INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, BF16, FLOAT16, FLOAT, DOUBLE, BOOL, HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, FLOAT8_E8M0 ND

Note: HIFLOAT8, FLOAT8_E5M2, FLOAT8_E4M3FN, and FLOAT8_E8M0 are supported only on Ascend 950PR&950DT products and are not supported on other products.

  • 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.

  • mode In REFLECT mode, the boundary itself is not included during mirroring. In SYMMETRIC mode, the boundary itself is included during mirroring, as shown in the example.

Constraint Description

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 reflection 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.

Invocation Description

Invocation Method Invocation Sample Description
aclnn invocation test_aclnn_reflection_pad_1d Invokes the mirror_pad operator in the REFLECT case through the aclnnReflectionPad1d API, and pads the last dimension of the input tensor.
aclnn invocation test_aclnn_reflection_pad_2d Invokes the mirror_pad operator in the REFLECT case through the aclnnReflectionPad2d API, and pads the last two dimensions of the input tensor.
aclnn invocation test_aclnn_reflection_pad_3d Invokes the mirror_pad operator in the REFLECT case through the aclnnReflectionPad3d API, and pads the last three dimensions of the input tensor.