Expand description
Shape and Strides - Tensor Dimension Management
Provides types and functions for managing tensor shapes, strides, and broadcasting rules. Shapes define the dimensions of a tensor, while strides define how to traverse the underlying storage.
§Key Features
- Efficient shape representation with small-vector optimization
- Stride computation for contiguous and transposed layouts
- Broadcasting support following
NumPyrules - Shape validation and manipulation
@version 0.1.0
@author AutomataNexus Development Team
Functions§
- broadcast_
shape - Computes the broadcast shape of two shapes.
- broadcast_
strides - Computes broadcast strides for a shape to match a target shape.
- can_
broadcast - Checks if two shapes are broadcastable.
- contiguous_
strides - Computes row-major (C-order) strides for a shape.
- is_
contiguous - Checks if strides represent a contiguous memory layout.
- linear_
index - Computes the linear index from multi-dimensional indices.
- normalize_
dim - Normalizes a dimension index, supporting negative indexing.
- numel
- Computes the total number of elements from a shape.
- reshape
- Reshapes a tensor shape, validating that total elements match.
- squeeze
- Computes the shape after squeezing (removing dimensions of size 1).
- transpose_
shape - Computes the shape after transposing dimensions.
- transpose_
strides - Swaps two stride values.
- unravel_
index - Converts a linear index to multi-dimensional indices.
- unsqueeze
- Computes the shape after unsqueezing (adding a dimension of size 1).
- validate_
indices - Validates that indices are within bounds for a shape.