Session Tensor Operations #
This file is the shared execution-mode dispatch layer for elementary tensor operations. It keeps
the public Session API uniform while routing each operation to either the eager tape or the typed
SSA graph session.
Elementwise addition (dispatches by execution mode).
Instances For
Elementwise subtraction (dispatches by execution mode).
Instances For
Elementwise multiplication (dispatches by execution mode).
Instances For
Scale a tensor by a scalar constant c (elementwise).
PyTorch analogy: x * c or torch.mul(x, c).
Instances For
Dropout implemented as a Session-level derived op.
In training mode, this records $$ y=\frac{x\odot\mathtt{mask}}{1-p}, $$
where $\mathtt{mask}\in\{0,1\}$ is generated by the Torch primitive bernoulliMask.
RNG Semantics (JAX-style / functional RNG) #
Randomness is a deterministic function of explicit session state:
- we read
(seed, counter)from the session-levelRngState, - derive a per-call
opSeeddeterministically, and - advance the
RngState(updateseed, incrementcounter).
Important: the bernoulli_mask op also mixes in a backend-internal counter (approximately: current
tape size / node index). So even with the same RngState, changing the surrounding graph structure
can change the exact samples. This is still fully deterministic for a fixed graph.
In evaluation mode (train=false) and at p = 0, this is the identity. At p = 1, training
returns zero. Other values must satisfy $0 < p < 1$.
Instances For
Elementwise absolute value (dispatches by execution mode).
Instances For
Elementwise square root (dispatches by execution mode).
Instances For
Elementwise clamp to [minVal, maxVal] (dispatches by execution mode).
Instances For
Elementwise maximum (dispatches by execution mode).
Instances For
Elementwise minimum (dispatches by execution mode).
Instances For
Matrix multiplication with broadcasted batch prefixes.
Instances For
Concatenate along the outermost dimension (dimension 0) (dispatches to eager vs typed graph backend).
Instances For
Slice a contiguous [start, start+len) range from dimension 0.
PyTorch analogy: x[start:start+len] for the first dimension.
Instances For
Apply max pooling over an arbitrary number of spatial axes.
Instances For
Apply smooth max pooling over an arbitrary number of spatial axes.
Instances For
Apply average pooling over an arbitrary number of spatial axes.