pub struct StridedLayout { /* private fields */ }Expand description
Strided tensor layout for efficient views and slicing
Implementations§
Source§impl StridedLayout
impl StridedLayout
Sourcepub fn new(shape: Vec<usize>) -> Self
pub fn new(shape: Vec<usize>) -> Self
Create a new strided layout with default C-contiguous strides
Sourcepub fn with_strides(
shape: Vec<usize>,
strides: Vec<isize>,
offset: usize,
) -> Result<Self>
pub fn with_strides( shape: Vec<usize>, strides: Vec<isize>, offset: usize, ) -> Result<Self>
Create layout with custom strides
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Check if the layout is contiguous (C-order)
Sourcepub fn is_fortran_contiguous(&self) -> bool
pub fn is_fortran_contiguous(&self) -> bool
Check if the layout is Fortran contiguous (F-order)
Sourcepub fn linear_index(&self, indices: &[usize]) -> Result<usize>
pub fn linear_index(&self, indices: &[usize]) -> Result<usize>
Compute the linear index for a multi-dimensional index
Sourcepub fn slice(&self, ranges: &[Range<usize>]) -> Result<Self>
pub fn slice(&self, ranges: &[Range<usize>]) -> Result<Self>
Create a view by slicing along dimensions
Sourcepub fn slice_with_stride(&self, slice_params: &[SliceParams]) -> Result<Self>
pub fn slice_with_stride(&self, slice_params: &[SliceParams]) -> Result<Self>
Create a view by slicing along dimensions with stride support
Sourcepub fn reshape(&self, new_shape: Vec<usize>) -> Result<Self>
pub fn reshape(&self, new_shape: Vec<usize>) -> Result<Self>
Reshape the layout (only works if contiguous)
Sourcepub fn broadcast_to(&self, target_shape: &[usize]) -> Result<Self>
pub fn broadcast_to(&self, target_shape: &[usize]) -> Result<Self>
Broadcast to a new shape
Sourcepub fn indices_iter(&self) -> StridedIndicesIter ⓘ
pub fn indices_iter(&self) -> StridedIndicesIter ⓘ
Create an iterator over all valid indices
Trait Implementations§
Source§impl Clone for StridedLayout
impl Clone for StridedLayout
Source§fn clone(&self) -> StridedLayout
fn clone(&self) -> StridedLayout
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StridedLayout
impl Debug for StridedLayout
Source§impl PartialEq for StridedLayout
impl PartialEq for StridedLayout
impl Eq for StridedLayout
impl StructuralPartialEq for StridedLayout
Auto Trait Implementations§
impl Freeze for StridedLayout
impl RefUnwindSafe for StridedLayout
impl Send for StridedLayout
impl Sync for StridedLayout
impl Unpin for StridedLayout
impl UnsafeUnpin for StridedLayout
impl UnwindSafe for StridedLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more