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 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 Shape.size s₁ = Shape.size s₂.
PyTorch comparison: x.reshape(new_shape) / x.view(new_shape) (when valid).
Instances For
Transpose a 2D matrix. PyTorch: x.t() / x.transpose(0,1).
Instances For
Permute a 3D tensor (a,b,c) → (b,c,a). PyTorch: x.permute(1,2,0).
Instances For
Permute a 3D tensor (a,b,c) → (c,a,b). PyTorch: x.permute(2,0,1).
Instances For
Swap the last two axes of a 3D tensor (a,b,c) → (a,c,b). PyTorch: x.transpose(1,2).
Instances For
Swap adjacent axes at a given depth inside a general Shape.
This is a more general analogue of transpose operations.
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).