Nx_core.ViewSourceTensor view: strided view of tensor data.
Views describe how to interpret a linear buffer as a multi-dimensional array through shape, strides, and offset. Supports non-contiguous layouts and masked regions.
View encapsulating tensor layout information.
val create :
?offset:int ->
?strides:int array ->
?mask:(int * int) array ->
Symbolic_shape.t ->
tcreate ?offset ?strides ?mask shape constructs view.
Default offset is 0. Default strides are C-contiguous. Mask specifies valid ranges per dimension as (start, end) pairs.
shape view returns dimension sizes.
numel view returns total elements (may be symbolic).
dim axis view returns size of dimension axis.
mask view returns valid bounds per dimension if masked.
linear_index view indices computes buffer position.
Includes view's offset in result.
is_valid view indices checks mask bounds.
Returns true if no mask or indices within all bounds.
reshape view new_shape changes dimensions.
Returns view if possible, fails if requires reordering. Handles -1 dimensions and size-1 squeezing/unsqueezing.
expand view new_shape broadcasts singleton dimensions.
Size-1 dimensions become size-n with stride 0.
shrink view bounds restricts to sub-region.
Bounds are (start, end) pairs per dimension.
pad view padding extends dimensions virtually.
Padding is (before, after) pairs. Creates mask for valid region.
flip view axes_to_flip reverses specified dimensions.
Adjusts strides to negative and updates offset.
merge view1 view2 attempts to compose two views.
Returns a single view representing the composition of view1 followed by view2, or None if the views cannot be merged.