mlx.core.slice#
- slice(a: array, start_indices: array, axes: Sequence[int], slice_size: Sequence[int], *, stream: None | Stream | Device = None) array #
Extract a sub-array from the input array.
- Parameters:
- Returns:
The sliced output array.
- Return type:
Example
>>> a = mx.array([[1, 2, 3], [4, 5, 6]]) >>> mx.slice(a, start_indices=mx.array(1), axes=(0,), slice_size=(1, 2)) array([[4, 5]], dtype=int32) >>> >>> mx.slice(a, start_indices=mx.array(1), axes=(1,), slice_size=(2, 1)) array([[2], [5]], dtype=int32)