FilesLast commitLast update
2 months ago
2 months ago
2 months ago
29 days ago
3 months ago
2 months ago
29 days ago
1 month ago
5 days ago
README

Trilu

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: for the matrix formed by the last two dimensions of the input tensor, retains the elements in the upper or lower triangular region based on the upper attribute, and sets the other elements to zero.

  • Computation formula:

When upper = 1 (upper triangular mode):y[row,col]={x[row,col]if col−row≥diagonal0otherwise\text{When upper = 1 (upper triangular mode):} \quad y[row, col] = \begin{cases} x[row, col] & \text{if } col - row \ge diagonal \\ 0 & \text{otherwise} \end{cases}

When upper = 0 (lower triangular mode):y[row,col]={x[row,col]if col−row≤diagonal0otherwise\text{When upper = 0 (lower triangular mode):} \quad y[row, col] = \begin{cases} x[row, col] & \text{if } col - row \le diagonal \\ 0 & \text{otherwise} \end{cases}

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input Input parameter for the triangular mask computation. The rank is at least 2, and the last two dimensions form a matrix. FLOAT, FLOAT16, DOUBLE, BFLOAT16, INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64, BOOL, COMPLEX32, COMPLEX64 ND
k Input (optional) Diagonal offset. 0 indicates the main diagonal, a positive value indicates the superdiagonal, and a negative value indicates the subdiagonal. The default value is 0. INT32, INT64 ND
upper Attribute Triangular region flag. 1 indicates the upper triangle, and 0 indicates the lower triangle. The default value is 0. INT64 -
y Output Output tensor after the triangular mask computation, whose shape is exactly the same as that of the input x. Same as the input x ND
  • 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

  • The input x must satisfy rank >= 2 (ND format), and the last two dimensions form a matrix.
  • 0D and 1D inputs are not supported. Such inputs return GRAPH_FAILED in the Tiling phase.

Invocation Description

Invocation Method Invocation Sample Description
Graph-mode invocation test_geir_trilu Invokes the trilu operator by building a graph through the GE IR on the host side.