Skip to main content

TensorStorage

Trait TensorStorage 

Source
pub trait TensorStorage:
    Send
    + Sync
    + Debug
    + Display
    + DynEq
    + Downcast {
    // Required methods
    fn byte_len(&self) -> usize;
    fn is_empty(&self) -> bool;
    fn deep_clone(&self) -> Box<dyn TensorStorage>;
    fn as_plain(&self) -> Option<&PlainStorage>;
    fn as_plain_mut(&mut self) -> Option<&mut PlainStorage>;
    fn into_plain(self: Box<Self>) -> Option<PlainStorage>;
    fn dyn_hash(&self, state: &mut dyn Hasher);
    fn exotic_fact(
        &self,
        shape: &[usize],
    ) -> Result<Option<Box<dyn ExoticFact>>, Error>;
}
Expand description

Trait abstracting over tensor storage backends.

PlainStorage is the primary implementation backed by a contiguous Blob. Non-plain backends are held behind StorageKind::Exotic(Box<dyn TensorStorage>).

Required Methods§

Source

fn byte_len(&self) -> usize

Source

fn is_empty(&self) -> bool

Source

fn deep_clone(&self) -> Box<dyn TensorStorage>

Source

fn as_plain(&self) -> Option<&PlainStorage>

Source

fn as_plain_mut(&mut self) -> Option<&mut PlainStorage>

Source

fn into_plain(self: Box<Self>) -> Option<PlainStorage>

Source

fn dyn_hash(&self, state: &mut dyn Hasher)

Source

fn exotic_fact( &self, shape: &[usize], ) -> Result<Option<Box<dyn ExoticFact>>, Error>

Build the ExoticFact that describes this storage for use in TypedFact.

Plain storage returns None. Exotic storages should return the appropriate fact so that From<Arc<Tensor>> for TypedFact preserves exotic-ness.

Implementations§

Source§

impl dyn TensorStorage

Source

pub fn is<__T>(&self) -> bool
where __T: TensorStorage,

Returns true if the trait object wraps an object of type __T.

Source

pub fn downcast<__T>( self: Box<dyn TensorStorage>, ) -> Result<Box<__T>, Box<dyn TensorStorage>>
where __T: TensorStorage,

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

Source

pub fn downcast_rc<__T>( self: Rc<dyn TensorStorage>, ) -> Result<Rc<__T>, Rc<dyn TensorStorage>>
where __T: TensorStorage,

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

Source

pub fn downcast_ref<__T>(&self) -> Option<&__T>
where __T: TensorStorage,

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

Source

pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>
where __T: TensorStorage,

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Trait Implementations§

Source§

impl<'eq> PartialEq<&Box<dyn TensorStorage + 'eq>> for Box<dyn TensorStorage + 'eq>

Source§

fn eq(&self, other: &&Box<dyn TensorStorage + 'eq>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq<&Box<dyn TensorStorage + Send + 'eq>> for Box<dyn TensorStorage + Send + 'eq>

Source§

fn eq(&self, other: &&Box<dyn TensorStorage + Send + 'eq>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq<&Box<dyn TensorStorage + Send + Sync + 'eq>> for Box<dyn TensorStorage + Send + Sync + 'eq>

Source§

fn eq(&self, other: &&Box<dyn TensorStorage + Send + Sync + 'eq>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq<&Box<dyn TensorStorage + Sync + 'eq>> for Box<dyn TensorStorage + Sync + 'eq>

Source§

fn eq(&self, other: &&Box<dyn TensorStorage + Sync + 'eq>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq for dyn TensorStorage + 'eq

Source§

fn eq(&self, other: &(dyn TensorStorage + 'eq)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq for dyn TensorStorage + Send + 'eq

Source§

fn eq(&self, other: &(dyn TensorStorage + Send + 'eq)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq for dyn TensorStorage + Send + Sync + 'eq

Source§

fn eq(&self, other: &(dyn TensorStorage + Send + Sync + 'eq)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq for dyn TensorStorage + Sync + 'eq

Source§

fn eq(&self, other: &(dyn TensorStorage + Sync + 'eq)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> Eq for dyn TensorStorage + 'eq

Source§

impl<'eq> Eq for dyn TensorStorage + Send + 'eq

Source§

impl<'eq> Eq for dyn TensorStorage + Send + Sync + 'eq

Source§

impl<'eq> Eq for dyn TensorStorage + Sync + 'eq

Implementations on Foreign Types§

Source§

impl TensorStorage for BlockQuantStorage

Source§

impl TensorStorage for PackedMatrixStorage

Implementors§