Nx_core.ShapeSourceConcrete shape operations.
Concrete tensor shapes.
A shape is an array of non-negative dimension sizes in row-major order.
The type for concrete shapes.
c_contiguous_strides shape is the row-major stride vector of shape.
For any zero-size dimension, strides to its left are propagated with zero according to the implementation's canonical rule.
ravel_index indices strides is the linear offset sum_i (indices.(i) * strides.(i)).
Raises Invalid_argument if the array lengths differ.
Note. This function does not perform bounds checks on indices.
unravel_index k shape is the multi-index of k in a C-contiguous layout of shape.
For shape = [||], k must be 0.
For zero-size shapes, only k = 0 is accepted and the result is an array of zeros with the same rank as shape.
Raises Invalid_argument if k is out of bounds for shape.
unravel_index_into k shape dst is like unravel_index but writes indices into dst.
dst must have length Array.length shape.
Raises Invalid_argument if k is out of bounds for shape.
Warning. If dst has the wrong length, array access may raise Invalid_argument via OCaml's bounds checks.
resolve_neg_one current_shape new_spec resolves a single -1 entry in new_spec using numel current_shape.
Raises Invalid_argument if:
new_spec contains more than one -1.broadcast a b is the broadcasted shape of a and b using NumPy rules (right alignment; dimensions are compatible iff equal or one is 1).
Raises Invalid_argument if the shapes are not broadcast-compatible.
broadcast_index target_idx source_shape maps a target index to the corresponding index in source_shape under broadcasting.
Dimensions of source_shape equal to 1 map to index 0.
broadcast_index_into target_idx source_shape dst is like broadcast_index but writes into dst.
dst must have length Array.length source_shape.
pp formats shapes with the same syntax as to_string.