Return the lower triangular part of a matrix or a batch of matrices. Parameters ---------- x : relax.Expr The tensor that tril will be applied to. It is required to have at least two dimensions. k : int The index indicating the diagonal above which to zero e
(x: Expr, k: int | PrimExpr | Expr = 0)
| 316 | |
| 317 | |
| 318 | def tril(x: Expr, k: int | PrimExpr | Expr = 0) -> Expr: |
| 319 | """Return the lower triangular part of a matrix or a batch of matrices. |
| 320 | |
| 321 | Parameters |
| 322 | ---------- |
| 323 | x : relax.Expr |
| 324 | The tensor that tril will be applied to. |
| 325 | It is required to have at least two dimensions. |
| 326 | |
| 327 | k : int |
| 328 | The index indicating the diagonal above which to zero elements. |
| 329 | If k = 0, the diagonal is the main diagonal. |
| 330 | If k < 0, the diagonal is below the main diagonal. |
| 331 | If k > 0, the diagonal is above the main diagonal. |
| 332 | |
| 333 | Returns |
| 334 | ------- |
| 335 | ret : relax.Expr |
| 336 | The result tensor. |
| 337 | """ |
| 338 | if not isinstance(k, Expr): |
| 339 | k = PrimValue(k) |
| 340 | |
| 341 | return _ffi_api.tril(x, k) # type: ignore |
| 342 | |
| 343 | |
| 344 | def triu(x: Expr, k: int | PrimExpr | Expr = 0) -> Expr: |