pub struct Metadata {
pub shape: Shape,
pub strides: Strides,
pub tiling: Tiling,
}Fields§
§shape: Shape§strides: Strides§tiling: TilingHow many fragments each logical dim is stored as; untiled by default.
The shape and strides stay physical. See Tiling.
Implementations§
Source§impl Metadata
impl Metadata
pub fn new(shape: impl Into<Shape>, strides: impl Into<Strides>) -> Metadata
Sourcepub fn with_tiling(self, tiling: Tiling) -> Result<Metadata, MetadataError>
pub fn with_tiling(self, tiling: Tiling) -> Result<Metadata, MetadataError>
This metadata with tiling labelling its physical dims.
§Errors
When tiling does not describe this rank: see Tiling::new.
Sourcepub fn logical_rank(&self) -> Result<usize, MetadataError>
pub fn logical_rank(&self) -> Result<usize, MetadataError>
How many dims this buffer stands for: its rank, less the extra fragments the tiling splits dims into.
§Errors
When the tiling does not fit this rank: see Tiling::logical_rank.
Sourcepub fn logical_shape(&self) -> Result<Shape, MetadataError>
pub fn logical_shape(&self) -> Result<Shape, MetadataError>
The extents this buffer stands for: each logical dim’s fragments multiplied back together, in logical order. An untiled metadata gives its shape unchanged.
§Errors
When the tiling does not fit this rank: see Tiling::logical_rank.
pub fn shape(&self) -> &Shape
Sourcepub fn shape_mut(&mut self) -> &mut Shape
pub fn shape_mut(&mut self) -> &mut Shape
The shape, to rewrite in place. A storage-tiled tensor’s dims are its tiling’s fragments, which a rewrite would leave stale, so it refuses like the dim-changing ops do.
pub fn strides(&self) -> &Strides
Sourcepub fn strides_mut(&mut self) -> &mut Strides
pub fn strides_mut(&mut self) -> &mut Strides
The strides, to rewrite in place. Refuses on a storage-tiled tensor, as
shape_mut does: its strides step its tiles, and a rewrite would
keep the tiling over strides that no longer do.
pub fn rank(&self) -> usize
pub fn num_dims(&self) -> usize
Sourcepub fn num_elements(&self) -> usize
pub fn num_elements(&self) -> usize
Returns the total number of elements of a tensor having this shape
pub fn swapped(self, dim0: usize, dim1: usize) -> Metadata
pub fn swap(&mut self, dim0: usize, dim1: usize)
Sourcepub fn permute(&mut self, axes: &[usize]) -> Result<(), MetadataError>
pub fn permute(&mut self, axes: &[usize]) -> Result<(), MetadataError>
Reorder the shape dimensions according to the permutation of axes.
pub fn permuted(self, axes: &[usize]) -> Result<Metadata, MetadataError>
Sourcepub fn insert(&mut self, index: usize, shape: usize, stride: usize)
pub fn insert(&mut self, index: usize, shape: usize, stride: usize)
Insert a dimension of shape with stride at position index.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Metadata
impl<'de> Deserialize<'de> for Metadata
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Metadata, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Metadata, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Metadata
Source§impl Ord for Metadata
impl Ord for Metadata
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Metadata
impl PartialOrd for Metadata
Source§impl Serialize for Metadata
impl Serialize for Metadata
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
key and return true if they are equal.