boundlab.expr.TupleExpr#
- class boundlab.expr.TupleExpr[source]#
Bases:
objectA base class for expressions that represent multiple tensors as a tuple. Usually a output of a multi-output operation, such as torch.chunk or a convolution that returns both output and pre-activation.
This is used to represent multiple outputs from a single operation, such as the two outputs of a convolution (output and pre-activation). TupleExpr is not intended to be used directly by users; it is an implementation detail for handling multi-output operations.
To simplify Expr APIs, TupleExpr is not a subclass of Expr and does not support the full expression interface. It resembles Expr in that it has a unique ID and can be used as a child of Expr through GetTupleItem, but its shape is a tuple of torch.Size, and its backward methods takes multiple weights operators corresponding to each output.
- children#
A tuple of sub-expressions.
Methods
Perform backward-mode bound propagation through this expression.
Convert this expression to a string for debugging purposes.
Return a new TupleExpr with the same flags but new children.
- property shape: tuple[torch.Size, ...]#
- property children: tuple[Expr, ...]#
Children expressions that contribute to this TupleExpr. This is used for topological sorting and weight propagation.
- backward(*weights, direction='==')[source]#
Perform backward-mode bound propagation through this expression.