Skip to content

UpperTriangularLinear

Bases: BaseModule

Linear layer with an upper-triangular weight, optionally extended with dense rows.

Designed to support in-place inference with a buffer of size max(in_features, out_features):

  • When out <= in the weight is pure upper triangular.
  • When out > in the first in rows are upper triangular and the remaining out - in rows are fully dense.

Parameters:

Name Type Description Default
in_features int

Number of input features.

required
out_features int

Number of output features.

required
bias bool

Whether to include an additive bias term.

True
device str

Torch device for the parameters.

'cpu'
act_func str | None

Either "relu" or None.

None