pub struct Layout { /* private fields */ }Expand description
The layout describes the memory layout of a tensor.
Implementations§
Source§impl Layout
impl Layout
pub unsafe fn new( offset: usize, shape: impl IntoShape, strides: impl IntoStride, ) -> Self
Sourcepub fn contiguous(shape: impl IntoShape) -> Self
pub fn contiguous(shape: impl IntoShape) -> Self
Create a new layout with a contiguous stride.
Sourcepub fn broadcast_as(&self, shape: impl IntoShape) -> ShapeResult<Self>
pub fn broadcast_as(&self, shape: impl IntoShape) -> ShapeResult<Self>
Broadcast the layout to a new shape.
The new shape must have the same or higher rank than the current shape.
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Determine if the current layout is contiguous or not.
Sourcepub fn is_square(&self) -> bool
pub fn is_square(&self) -> bool
A function for determining if the layout is square. An n-dimensional object is square if all of its dimensions are equal.
pub fn iter(&self) -> LayoutIter ⓘ
Sourcepub fn offset_from_low_addr_ptr_to_logical_ptr(&self) -> usize
pub fn offset_from_low_addr_ptr_to_logical_ptr(&self) -> usize
Returns the offset from the lowest-address element to the logically first element.
Sourcepub fn remove_axis(&self, axis: Axis) -> Self
pub fn remove_axis(&self, axis: Axis) -> Self
Remove an axis from the current layout, returning the new layout.
Sourcepub fn reverse_axes(self) -> Layout
pub fn reverse_axes(self) -> Layout
Reverse the order of the axes.
pub fn with_offset(self, offset: usize) -> Self
pub fn with_shape_c(self, shape: impl IntoShape) -> Self
pub unsafe fn with_shape_unchecked(self, shape: impl IntoShape) -> Self
pub unsafe fn with_strides_unchecked(self, stride: impl IntoStride) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Layout
impl<'de> Deserialize<'de> for Layout
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Layout
impl Ord for Layout
Source§impl PartialOrd for Layout
impl PartialOrd for Layout
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 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