Proof-Linked Session: Basic Graph Operations #
Graph-node ops (implemented by reusing Compiled.GraphM) #
Run a Compiled.GraphM computation against the current (ss, g) pair.
Compiled.GraphM is the builder monad used by the proof-friendly compiled pipeline; reusing it
here ensures this eager-style API records the same typed IR that the compiler expects.
Instances For
Atomically apply a graph-building update to the session snapshot.
This is the central adapter used by each op wrapper below: it reads s.st, runs a builder that
returns an updated SessionIRState, stores it back into s.st, and returns the op result.
Instances For
Record a constant tensor.
Subtlety: if no op nodes have been created yet (ss = []), we record const as a leaf to match
the eager session's leaf-collection behavior. Once op nodes exist, we emit an explicit constant node
so users can introduce literal constants mid-graph.
PyTorch comparison: like torch.tensor(...) (a leaf) vs inserting a literal constant into the
graph; constants are treated as non-requires-grad.
Instances For
Record elementwise addition a + b.
PyTorch comparison: torch.add(a, b) / the + operator.
Instances For
Record elementwise subtraction a - b.
PyTorch comparison: torch.sub(a, b) / the - operator.
Instances For
Record elementwise multiplication a * b.
PyTorch comparison: torch.mul(a, b) / the * operator.
Instances For
Record scaling by a scalar constant: x * c.
PyTorch comparison: like x * c (where c is a Python scalar).
Instances For
Record elementwise absolute value.
PyTorch comparison: torch.abs(x).
Instances For
Stop-gradient boundary.
Forward semantics: identity.
Backward semantics: no gradient flows to the input.
PyTorch comparison: x.detach().
Instances For
Record elementwise square root.
PyTorch comparison: torch.sqrt(x).
Instances For
Record elementwise clamp to the interval [minVal, maxVal].
PyTorch comparison: torch.clamp(x, min=minVal, max=maxVal).
Instances For
Record elementwise maximum of a and b.
PyTorch comparison: torch.maximum(a, b).
Instances For
Record elementwise minimum of a and b.
PyTorch comparison: torch.minimum(a, b).
Instances For
Record 2D matrix multiplication.
PyTorch comparison: torch.matmul(a, b) for 2D tensors.
Instances For
Record batched matrix multiplication.
PyTorch comparison: torch.bmm(a, b) for 3D tensors of shape (batch, m, n) and (batch, n, p).
Instances For
Concatenate two 1D vectors along dimension 0.
PyTorch comparison: torch.cat([a, b], dim=0) for 1D tensors.
Instances For
Concatenate two tensors along dimension 0.
PyTorch comparison: torch.cat([a, b], dim=0).
Instances For
Slice a tensor along dimension 0.
This returns x[start : start+len]. The proof argument h enforces bounds.
PyTorch comparison: x[start:start+len] for tensors with a leading dimension.