Nx_core.ShapeSourceShape operations for multi-dimensional arrays.
This module provides fundamental operations on array shapes including index conversions, broadcasting, and stride calculations.
Shape representation as array of dimension sizes.
c_contiguous_strides shape computes row-major strides.
Handles zero-size dimensions correctly.
ravel_index indices strides computes linear offset.
unravel_index offset shape converts to multi-dimensional indices.
Assumes C-contiguous layout.
unravel_index_into offset shape result writes indices into result array.
In-place version to avoid allocations in loops.
resolve_neg_one current_shape new_spec infers dimension marked with -1.
broadcast shape_a shape_b computes broadcast result shape.
Follows NumPy rules: dimensions match if equal or one is 1.
broadcast_index target_indices source_shape maps indices for broadcasting.
Returns indices in source shape corresponding to target position.
broadcast_index_into target_indices source_shape result writes broadcast indices into result array.
In-place version to avoid allocations in loops.
pp fmt shape prints shape in 2x3x4 format.