Shape/axis helpers #
Swap two adjacent axes at a given nesting depth.
This is the primitive used to implement general permutations via a sequence of adjacent swaps.
It corresponds to the backend op Torch.swapAdjacentAtDepth.
Instances For
Core tensor semantics (PyTorch-style) #
Detect duplicate axes in a runtime axis array.
Instances For
Dynamic permutation: like permute, but returns an existential output shape.
PyTorch analogue: torch.permute / Tensor.permute (with runtime checks).
Instances For
Permutation with an expected output shape.
This calls permute? and checks that the computed shape equals sOut.
Instances For
Exchange two arbitrary axes and check the statically expected output shape.
The result is none when either axis is invalid or the transposed shape is not sOut.
Instances For
Reduce along the last axis with sum, returning the new (existential) shape.
This is the primitive step used by reduceAxesCore after it has permuted the requested axis to
the last position.
Instances For
Like reduceAlongLastSum, but using mean.
Instances For
Core implementation for reductions over a runtime array of axes.
This lowers “reduce along axis k” to:
- permute axis
kto the last position, - call
reduceLast, and - optionally re-insert a singleton dimension when
keepdim = true.
reduceSumDims? and reduceMeanDims? specialize this operation.
Instances For
Dynamic multi-axis sum reduction (like torch.sum(x, dim=axes, keepdim=...)).
Instances For
Dynamic multi-axis mean reduction (like torch.mean(x, dim=axes, keepdim=...)).
Instances For
Softmax along any valid tensor dimension.
The selected dimension is moved to the end for the backend's row-softmax primitive and then moved
back. The reverse-swap theorem makes the result shape exactly s; no runtime shape check is needed.
Instances For
Log-softmax along any valid tensor dimension.