Implementing kernel
C++ engine symbols that back this Python API.Return the lower-triangular part of a 2-D-or-higher tensor.
Elements above the diagonal-th diagonal (where j > i + diagonal) are
zeroed out. Batched matrices are supported — the operation is
applied independently to each trailing 2-D slice.
Parameters
inputTensorSource tensor with
ndim >= 2.diagonalint= 0Diagonal offset.
0 keeps the main diagonal; positive values
keep additional super-diagonals; negative values exclude
sub-diagonals.Returns
TensorTensor of the same shape as input.
Notes
The complementary upper-triangular extraction is triu. Note
that input need not be square.
Examples
>>> import lucid
>>> A = lucid.ones(3, 3)
>>> lucid.tril(A)
tensor([[1., 0., 0.], [1., 1., 0.], [1., 1., 1.]])