pub struct Layout { /* private fields */ }Implementations§
Source§impl Layout
impl Layout
pub fn new<S: Into<Shape>>( shape: S, stride: Vec<usize>, start_offset: usize, ) -> Self
pub fn contiguous<S: Into<Shape>>(shape: S) -> Self
pub fn contiguous_with_offset<S: Into<Shape>>( shape: S, start_offset: usize, ) -> Self
pub fn dims(&self) -> &[usize]
pub fn dim<D: Dim>(&self, dim: D) -> Result<usize>
pub fn shape(&self) -> &Shape
pub fn stride(&self) -> &[usize]
pub fn start_offset(&self) -> usize
pub fn element_count(&self) -> usize
pub fn is_contiguous(&self) -> bool
pub fn slice( &self, dim: usize, start: usize, end: usize, step: usize, ) -> Result<Self>
pub fn narrow(&self, dim: usize, start: usize, len: usize) -> Result<Self>
pub fn transpose(&self, dim1: usize, dim2: usize) -> Result<Self>
pub fn broadcast_as<S: Into<Shape>>(&self, shape: S) -> Result<Self>
pub fn permute(&self, idxs: &[usize]) -> Result<Self>
Sourcepub fn storage_indices(&self) -> StorageIndices<'_> ⓘ
pub fn storage_indices(&self) -> StorageIndices<'_> ⓘ
Returns an iterator over storage indices.
This iterator yields the linear (flat) indices as they are laid out in the underlying storage buffer. The order depends on the memory layout (e.g., row-major / column-major / with strides).
Example for shape = (2, 2) in row-major layout:
yields: 0, 1, 2, 3
Trait Implementations§
impl Eq for Layout
impl StructuralPartialEq for Layout
Auto Trait Implementations§
impl Freeze for Layout
impl RefUnwindSafe for Layout
impl Send for Layout
impl Sync for Layout
impl Unpin for Layout
impl UnsafeUnpin for Layout
impl UnwindSafe for Layout
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