Description: Sets the elements of the input tensor
[object Object](last two dimensions) to[object Object]in the upper triangular part above the main diagonal. The diagonal parameter can be set to a positive or negative value. The default value is[object Object]. A positive value indicates diagonals above the main diagonal. A negative value indicates diagonals below the main diagonal.Formula: In the following formula,
[object Object]indicates the sequence number of the element in the second-to-last dimension ([object Object]is the row index),[object Object]indicates the sequence number of the element in the last dimension ([object Object]is the column index), and[object Object]indicates diagonal. In the two-dimensional coordinate diagram corresponding to (i, j), i+d==j indicates that the element is on the diagonal.Example:
, The result of triu(self, diagonal=0) is as follows:
;
Adjust the value of
[object Object]. The result of triu(self, diagonal=1) is as follows:;
Adjust the value of
[object Object]to[object Object]. The result of triu(self, diagonal=-1) is as follows:.
[object Object]and[object Object]implement the same function in different ways. Select a proper operator based on your requirements.[object Object]: An output tensor object needs to be created to store the computation result.[object Object]: No output tensor object needs to be created, and the computation result is stored in the memory of the input tensor.
- Each operator has calls. First,
[object Object]or[object Object]is called to obtain input parameters and calculate the required workspace size based on the computation process. Then,[object Object]or[object Object]is called to perform computation.
Parameters
[object Object]Returns
[object Object]: status code. For details, see .The first-phase API performs input parameter validation. The following errors may be returned:
[object Object]
Parameters
[object Object]Returns
[object Object]: status code. For details, see .The first-phase API performs input parameter validation. The following errors may be returned:
[object Object]
- Deterministic computation:
[object Object]defaults to a deterministic implementation.
The following example is for reference only. For details, see .