FilesLast commitLast update
9 days ago
9 months ago
25 days ago
9 months ago
17 days ago
10 months ago
12 days ago
17 days ago
1 month ago
16 days ago
README

Tril

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: sets the part above the diagonal in the last two dimensions (counted from left to right in the shape) of the input self tensor to zero. The parameter diagonal can be positive or negative, and the default value is 0. A positive value moves the main diagonal toward the upper right, and a negative value moves the main diagonal toward the lower left.

  • Computation formula: In the following, i denotes the index for traversing the elements of the second-to-last dimension (i is the row index), j denotes the index for traversing the elements of the last dimension (j is the column index), and d denotes diagonal. In the 2D coordinate map corresponding to (i, j), i+d==j indicates that the position is on the diagonal.

    Onandbelowthediagonal,thatis,i+d>=j,theoriginalvalueisretained:outi,j=selfi,jAbovethediagonal,thatis,i+d<j,thevalueissettozero(excludingthediagonal):outi,j=0On and below the diagonal, that is, i+d>=j, the original value is retained: out_{i, j} = self_{i, j}\\ Above the diagonal, that is, i+d<j, the value is set to zero (excluding the diagonal): out_{i, j} = 0

  • Example:

    self=[[963][123][341]]self = \begin{bmatrix} [9&6&3] \\ [1&2&3] \\ [3&4&1] \end{bmatrix}, the result of triu(self, diagonal=0) is: [[900][120][341]]\begin{bmatrix} [9&0&0] \\ [1&2&0] \\ [3&4&1] \end{bmatrix}; with a different value of diagonal, the result of triu(self, diagonal=1) is: [[960][123][341]]\begin{bmatrix} [9&6&0] \\ [1&2&3] \\ [3&4&1] \end{bmatrix}; with diagonal set to -1, the result of triu(self, diagonal=-1) is: [[000][100][340]]\begin{bmatrix} [0&0&0] \\ [1&0&0] \\ [3&4&0] \end{bmatrix}.

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
self Input Input parameter for the tril computation, which is self in the formula. FLOAT, FLOAT16, DOUBLE, BFLOAT16, INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64, BOOL, COMPLEX32, COMPLEX64 ND
diagonal Input Input parameter for the tril computation, which is diagonal in the formula. INT64 ND
out Output Output parameter for the tril computation, which is out_i in the formula. FLOAT, FLOAT16, DOUBLE, BFLOAT16, INT8, INT16, INT32, INT64, UINT8, BOOL ND
  • Atlas training products: The supported data types are DOUBLE, FLOAT, FLOAT16, INT16, INT32, INT64, INT8, UINT16, UINT32, UINT64, UINT8, and BOOL.
  • Atlas A2 products and Atlas A3 products: The supported data types are DOUBLE, FLOAT, FLOAT16, INT16, INT32, INT64, INT8, UINT16, UINT32, UINT64, UINT8, BOOL, and BFLOAT16.
  • Ascend 950PR&950DT products: The supported data types are DOUBLE, FLOAT, FLOAT16, INT16, INT32, INT64, INT8, UINT16, UINT32, UINT64, UINT8, BOOL, BFLOAT16, COMPLEX32, and COMPLEX64.

Constraint Description

None

Invocation Description

Invocation Method Invocation Sample Description
aclnn invocation test_aclnn_tril Invokes the Tril operator through the aclnnTril API.