| Files | Last commit | Last update |
|---|---|---|
| 13 days ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 4 months ago | ||
| 7 days ago | ||
| 2 months ago | ||
| 2 days ago | ||
| 7 days ago | ||
| 1 month ago | ||
| 6 days ago |
Triu
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 below 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.
Onandabovethediagonal,thatis,i+d<=j,theoriginalvalueisretained:outi,j=selfi,jBelowthediagonal,thatis,i+d>j,thevalueissettozero(excludingthediagonal):outi,j=0On and above the diagonal, that is, i+d<=j, the original value is retained: out_{i, j} = self_{i, j}\\ Below 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: [[963][023][001]]\begin{bmatrix} [9&6&3] \\ [0&2&3] \\ [0&0&1] \end{bmatrix}; with a different value of diagonal, the result of triu(self, diagonal=1) is: [[063][003][000]]\begin{bmatrix} [0&6&3] \\ [0&0&3] \\ [0&0&0] \end{bmatrix}; with diagonal set to -1, the result of triu(self, diagonal=-1) is: [[963][123][041]]\begin{bmatrix} [9&6&3] \\ [1&2&3] \\ [0&4&1] \end{bmatrix}.
Parameter Description
| Parameter Name | Input/Output/Attribute | Description | Data Type | Data Format |
|---|---|---|---|---|
| self | Input | Input parameter for the triu 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 triu computation, which is diagonal in the formula. | INT64 | ND |
| out | Output | Output parameter for the triu computation, which is out_i in the formula. | FLOAT, FLOAT16, DOUBLE, BFLOAT16, INT8, INT16, INT32, INT64, UINT8, BOOL | ND |
- Atlas inference products and Atlas training products: The supported data types are UINT64, INT64, UINT32, INT32, UINT16, INT16, UINT8, INT8, FLOAT16, FLOAT32, DOUBLE, and BOOL.
- Atlas A2 products and Atlas A3 products: The supported data types are UINT64, INT64, UINT32, INT32, UINT16, INT16, UINT8, INT8, FLOAT16, FLOAT32, DOUBLE, BOOL, and BFLOAT16.
- Ascend 950PR&950DT products: The supported data types are UINT64, INT64, UINT32, INT32, UINT16, INT16, UINT8, INT8, FLOAT16, FLOAT32, DOUBLE, BOOL, BFLOAT16, COMPLEX32, and COMPLEX64.
Constraint Description
None
Invocation Description
| Invocation Method | Invocation Sample | Description |
|---|---|---|
| aclnn invocation | test_aclnn_triu | Invokes the Triu operator through the aclnnTriu API. |