oneflow.triu¶
-
oneflow.
triu
()¶ Returns the upper triangular part of a matrix (2-D tensor) or batch of matrices input, the other elements of the result tensor out are set to 0.
- Parameters
input (Tensor) – the input tensor.
diagonal (int, optional) – the diagonal to consider
For example:
>>> import oneflow as flow >>> import numpy as np >>> x = flow.tensor(np.ones(shape=(3, 3)).astype(np.float32)) >>> flow.triu(x) tensor([[1., 1., 1.], [0., 1., 1.], [0., 0., 1.]], dtype=oneflow.float32)