Shape-changing eager-engine operations.
This module implements reshape, transpose, broadcast, slice, gather/scatter, and related view-style nodes while preserving the graph metadata needed by autograd.
Flatten a tensor s into a 1D vector of length Spec.Shape.size s.
PyTorch comparison: torch.flatten(x) with start_dim=0.
Instances For
Reshape a tensor while preserving number of elements.
The proof argument h enforces Spec.Shape.size s₁ = Spec.Shape.size s₂.
PyTorch comparison: x.reshape(new_shape) / x.view(new_shape) (when valid).
Instances For
Swap adjacent axes at a given depth inside a general Shape.
General permutations and arbitrary-axis transpose are lowered to this operation.
Instances For
Broadcast x : s₁ to s₂ using a proof Shape.CanBroadcastTo s₁ s₂.
PyTorch comparison: implicit broadcasting / x.expand(...).
Instances For
Sum-reduce along axis.
PyTorch comparison: torch.sum(x, dim=axis).
Instances For
Mean-reduce along axis.
Backward rule: broadcast the upstream cotangent back to s and divide by the reduced dimension.
PyTorch comparison: torch.mean(x, dim=axis).