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

Function triu

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

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)

Source from the content-addressed store, hash-verified

342
343
344def 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

Callers 1

triu_gradFunction · 0.70

Calls 2

PrimValueClass · 0.85
triuMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…