boundlab.expr.AffineSum#
- class boundlab.expr.AffineSum[source]#
Bases:
ExprAn expression representing a sum of linear operations applied to children.
Represents \(\sum_i \mathrm{op}_i(x_i)\) where each \(\mathrm{op}_i\) is a
EinsumOp.During construction, if a child is itself an
AffineSum, its pairs are absorbed by composing the outer op with each inner op via@(eager contraction). This ensures the expression tree is always flat — noAffineSumnode ever has anAffineSumchild.- pairs#
List of
(op, child)tuples.
- ops#
List of EinsumOp operators (convenience view).
Methods
Construct an AffineSum.
Propagate weights backward: each child gets weights ∘ op_i.
Compute the width of the bounds for this expression.
Compute the center of the bounds for this expression.
Return the concrete tensor if self is a pure constant expression, else None.
Recursively compute Jacobian ops for affine expressions.
Compute a lower bound for this expression.
Return string representation with child strings substituted.
Compute an upper bound for this expression.
Compute both an upper bound and a lower bound for this expression.
Return a new AffineSum with the same ops but new children.
- __init__(*pairs, const=None)[source]#
Construct an AffineSum.
- Parameters:
*pairs (tuple) – Sequence of
(op, child)pairs whereopis aEinsumOpandchildis anExprortorch.Tensor.
- property shape: torch.Size#
The shape of the output(s) produced by this expression.
- __add__(other)#
- __mul__(other)#
Element-wise multiplication (no broadcast).
- bound_width()#
Compute the width of the bounds for this expression.
- center()#
Compute the center of the bounds for this expression.
- diag(diagonal=0)#
- expand(*sizes)#
- flatten(start_dim=0, end_dim=-1)#
- flip(dims)#
- gather(indices)#
- get_const()#
Return the concrete tensor if self is a pure constant expression, else None.
Works for
ConstValand anyAffineSumthat has no symbolic children.
- lb()#
Compute a lower bound for this expression.
- narrow(dim, start, length)#
- permute(*dims)#
- repeat(*sizes)#
- reshape(*shape)#
- roll(shifts, dims)#
- scatter(indices, output_shape)#
- squeeze(dim=None)#
- tile(*sizes)#
- transpose(dim0, dim1)#
- ub()#
Compute an upper bound for this expression.
- ublb()#
Compute both an upper bound and a lower bound for this expression.
- unflatten(dim, sizes)#
- unsqueeze(dim)#
- zeros_set(output_shape)#