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],
    ) -> TractResult<Option<Box<dyn ExoticFact>>>;
}
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], ) -> TractResult<Option<Box<dyn ExoticFact>>>

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: TensorStorage>(&self) -> bool

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

Source

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

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: TensorStorage>( self: Rc<Self>, ) -> Result<Rc<__T>, Rc<Self>>

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: TensorStorage>(&self) -> Option<&__T>

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: TensorStorage>(&mut self) -> Option<&mut __T>

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: &&Self) -> 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: &&Self) -> 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: &&Self) -> 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: &&Self) -> 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: &Self) -> 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: &Self) -> 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: &Self) -> 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: &Self) -> 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

Implementors§