MCPcopy Create free account
hub / github.com/apache/tvm / tril

Function tril

python/tvm/relax/op/create.py:318–341  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

316
317
318def 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
344def triu(x: Expr, k: int | PrimExpr | Expr = 0) -> Expr:

Callers

nothing calls this directly

Calls 2

PrimValueClass · 0.85
trilMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…