Trilu

Description

Obtains the upper or lower triangular part of a two-dimensional matrix or a batch of two-dimensional matrices. That is, the shape of the input tensor is [*, N, M], where * indicates zero or more dimensions.

Input

input: tensor of type uint8, int8, int16, int32, bool, float, float16, float64, int64, with shape [*, N, M].

k (optional): offset of the main diagonal. Only setting k to 0 is supported.

Attribute

upper: int, specifying whether to retain the upper or lower triangular part of the matrix. If the value is 1, the upper triangular part is retained. If the value is 0, the lower triangular part is retained.

Output

output: tensor of the identical data type and shape as input.

Constraints

None.

ONNX Opset Support

Opset v14/v15/v16/v17/v18