Return the upper triangular part of a matrix or a batch of matrices. Parameters ---------- x : relax.Expr The tensor that triu will be applied to. It is required to have at least two dimensions. k : int The index indicating the diagonal below which to zero e
(x: Expr, k: int | PrimExpr | Expr = 0)
| 342 | |
| 343 | |
| 344 | def triu(x: Expr, k: int | PrimExpr | Expr = 0) -> Expr: |
| 345 | """Return the upper triangular part of a matrix or a batch of matrices. |
| 346 | |
| 347 | Parameters |
| 348 | ---------- |
| 349 | x : relax.Expr |
| 350 | The tensor that triu will be applied to. |
| 351 | It is required to have at least two dimensions. |
| 352 | |
| 353 | k : int |
| 354 | The index indicating the diagonal below which to zero elements. |
| 355 | If k = 0, the diagonal is the main diagonal. |
| 356 | If k < 0, the diagonal is below the main diagonal. |
| 357 | If k > 0, the diagonal is above the main diagonal. |
| 358 | |
| 359 | Returns |
| 360 | ------- |
| 361 | ret : relax.Expr |
| 362 | The result tensor. |
| 363 | """ |
| 364 | if not isinstance(k, Expr): |
| 365 | k = PrimValue(k) |
| 366 | |
| 367 | return _ffi_api.triu(x, k) # type: ignore |