pub struct DeviceView { /* private fields */ }Expand description
A window into a device buffer owned by someone else, described by shape, strides and a byte offset.
The buffer is kept alive by the Arc, but its contents are not: the turn
arena hands out windows at offsets the memory schema deliberately reuses,
and a state-owned buffer is written by the op that owns it. So a view is
good for the turn that produced it and no longer – it is read by the nodes
downstream of its producer, and copied out at the model boundary rather
than handed to the application.
Implementations§
Source§impl DeviceView
impl DeviceView
pub fn shape(&self) -> &[usize]
Sourcepub fn datum_type(&self) -> DatumType
pub fn datum_type(&self) -> DatumType
Get the datum type of the tensor.
pub fn strides(&self) -> &[isize]
Sourcepub fn device_buffer(&self) -> &dyn DeviceBuffer
pub fn device_buffer(&self) -> &dyn DeviceBuffer
Get underlying inner device buffer.
pub fn device_buffer_ptr(&self) -> *const c_void
Sourcepub fn buffer_offset<I: Copy + 'static>(&self) -> Iwhere
usize: AsPrimitive<I>,
pub fn buffer_offset<I: Copy + 'static>(&self) -> Iwhere
usize: AsPrimitive<I>,
Get underlying inner device buffer offset
pub fn exotic_fact(&self) -> Option<&dyn ExoticFact>
pub fn as_bytes(&self) -> Vec<u8> ⓘ
Sourcepub fn reshaped(&self, shape: impl Into<TVec<usize>>) -> TractResult<Self>
pub fn reshaped(&self, shape: impl Into<TVec<usize>>) -> TractResult<Self>
Reshaped tensor with given shape.
pub fn restrided(&self, strides: impl Into<TVec<isize>>) -> TractResult<Self>
Sourcepub fn is_packed(&self) -> bool
pub fn is_packed(&self) -> bool
True where the bytes of this view are the tensor, in order and with no gap: what a reader working from a pointer and a length may assume.
pub fn to_host(&self) -> TractResult<Tensor>
Trait Implementations§
Source§impl Clone for DeviceView
impl Clone for DeviceView
Source§impl Debug for DeviceView
impl Debug for DeviceView
Source§impl Display for DeviceView
impl Display for DeviceView
impl Eq for DeviceView
Source§impl From<DeviceView> for DeviceTensor
impl From<DeviceView> for DeviceTensor
Source§fn from(view: DeviceView) -> Self
fn from(view: DeviceView) -> Self
Source§impl Hash for DeviceView
impl Hash for DeviceView
Source§impl PartialEq for DeviceView
impl PartialEq for DeviceView
impl StructuralPartialEq for DeviceView
Auto Trait Implementations§
impl !RefUnwindSafe for DeviceView
impl !UnwindSafe for DeviceView
impl Freeze for DeviceView
impl Send for DeviceView
impl Sync for DeviceView
impl Unpin for DeviceView
impl UnsafeUnpin for DeviceView
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
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more