pub struct TensorViewMut<'a> { /* private fields */ }Expand description
The mutable counterpart of TensorView, obtained from a &mut Tensor (or split
out of raw bytes of a type where any bit pattern is valid), so writes through it never
alias another live view.
Implementations§
Source§impl<'a> TensorViewMut<'a>
impl<'a> TensorViewMut<'a>
Sourcepub fn from_pod_bytes(
dt: DatumType,
bytes: &'a mut [u8],
shape: &'a [usize],
strides: &'a [isize],
) -> TractResult<TensorViewMut<'a>>
pub fn from_pod_bytes( dt: DatumType, bytes: &'a mut [u8], shape: &'a [usize], strides: &'a [isize], ) -> TractResult<TensorViewMut<'a>>
A mutable view over raw bytes holding dt items. Only for datum types where
every bit pattern is a valid value.
pub fn view(&self) -> TensorView<'_>
pub fn datum_type(&self) -> DatumType
pub fn shape(&self) -> &'a [usize]
pub fn strides(&self) -> &'a [isize]
pub fn rank(&self) -> usize
Sourcepub fn offset_axis(&mut self, axis: usize, pos: usize) -> TractResult<()>
pub fn offset_axis(&mut self, axis: usize, pos: usize) -> TractResult<()>
Moves the view’s origin pos steps along axis, keeping its shape and strides.
Sourcepub fn as_ptr_mut<D: Datum>(&mut self) -> TractResult<*mut D>
pub fn as_ptr_mut<D: Datum>(&mut self) -> TractResult<*mut D>
The view’s origin, typed. Errors on a datum type mismatch.
Sourcepub unsafe fn as_ptr_mut_unchecked<D: Datum>(&mut self) -> *mut D
pub unsafe fn as_ptr_mut_unchecked<D: Datum>(&mut self) -> *mut D
The view’s origin, cast to D without checking the datum type.
Sourcepub fn as_slice<D: Datum>(&self) -> TractResult<&[D]>
pub fn as_slice<D: Datum>(&self) -> TractResult<&[D]>
len() contiguous items from the view’s origin.
Sourcepub fn as_slice_mut<D: Datum>(&mut self) -> TractResult<&mut [D]>
pub fn as_slice_mut<D: Datum>(&mut self) -> TractResult<&mut [D]>
len() contiguous items from the view’s origin.
Sourcepub unsafe fn as_slice_mut_unchecked<D: Datum>(&mut self) -> &mut [D]
pub unsafe fn as_slice_mut_unchecked<D: Datum>(&mut self) -> &mut [D]
Like Self::as_slice_mut, without checking the datum type, alignment or extent.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !UnwindSafe for TensorViewMut<'a>
impl<'a> Forget for TensorViewMut<'a>
impl<'a> Freeze for TensorViewMut<'a>
impl<'a> Move for TensorViewMut<'a>
impl<'a> RefUnwindSafe for TensorViewMut<'a>
impl<'a> Send for TensorViewMut<'a>
impl<'a> Sync for TensorViewMut<'a>
impl<'a> Unpin for TensorViewMut<'a>
impl<'a> UnsafeUnpin for TensorViewMut<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Converts
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>
Converts
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)
Converts
&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)
Converts
&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<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> ⓘ
Converts
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> ⓘ
Converts
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