Enum TensorMutable

Source
pub enum TensorMutable<'a, T, B, D>
where B: DeviceRawAPI<T>, D: DimAPI,
{ Owned(Tensor<T, B, D>), Mut(TensorMut<'a, T, B, D>), ToBeCloned(TensorMut<'a, T, B, D>, Tensor<T, B, D>), }
Expand description

Mutable tensor (either owned or mutable reference).

This is mostly used for inplace operations as output.

It is designed similar to TensorCow. However, if inplace operation is not convenient because of the layout contiguous not fulfilled, a ToBeCloned variant is provided, where an owned tensor with contiguous layout is generated. This is not the same to TensorCow, where it only involves ownership conversion, but not layout difference between two tensors. So this is defined as a special type.

Variants§

§

Owned(Tensor<T, B, D>)

§

Mut(TensorMut<'a, T, B, D>)

§

ToBeCloned(TensorMut<'a, T, B, D>, Tensor<T, B, D>)

Implementations§

Source§

impl<T, B, D> TensorMutable<'_, T, B, D>
where T: Clone, D: DimAPI, B: DeviceAPI<T> + DeviceCreationAnyAPI<T> + OpAssignAPI<T, D>,

Source

pub fn clone_to_mut(self) -> Self

Source

pub fn into_reverse_axes(self) -> Self

Source

pub fn f_prefer(&self) -> bool

Source

pub fn c_prefer(&self) -> bool

Source

pub fn f_contig(&self) -> bool

Source

pub fn c_contig(&self) -> bool

Source§

impl<T, B, D> TensorMutable<'_, T, B, D>
where T: Clone, D: DimAPI, B: DeviceAPI<T> + DeviceCreationAnyAPI<T> + OpAssignAPI<T, D>, B::Raw: Clone,

Source

pub fn to_owned(&self) -> Tensor<T, B, D>

Source§

impl<'a, T, B, D> TensorMutable<'a, T, B, D>
where T: Clone, D: DimAPI, B: DeviceAPI<T> + DeviceCreationAnyAPI<T> + OpAssignAPI<T, D>,

Source

pub fn into_dim_f<D2>(self) -> Result<TensorMutable<'a, T, B, D2>>
where D: DimIntoAPI<D2>, D2: DimAPI,

Source

pub fn into_dim<D2>(self) -> TensorMutable<'a, T, B, D2>
where D: DimIntoAPI<D2>, D2: DimAPI,

Trait Implementations§

Source§

impl<T, B, D> TensorIntoOwnedAPI<T, B, D> for TensorMutable<'_, T, B, D>
where T: Clone, D: DimAPI, B: DeviceAPI<T> + DeviceCreationAnyAPI<T> + OpAssignAPI<T, D>, B::Raw: Clone,

Source§

fn into_owned(self) -> Tensor<T, B, D>

Convert tensor into owned tensor. Read more
Source§

impl<T, B, D> TensorViewAPI<T, B, D> for TensorMutable<'_, T, B, D>
where D: DimAPI, B: DeviceAPI<T>,

Source§

fn view(&self) -> TensorView<'_, T, B, D>

Get a view of tensor.
Source§

impl<T, B, D> TensorViewMutAPI<T, B, D> for TensorMutable<'_, T, B, D>
where D: DimAPI, B: DeviceAPI<T>,

Source§

fn view_mut(&mut self) -> TensorViewMut<'_, T, B, D>

Get a mutable view of tensor.

Auto Trait Implementations§

§

impl<'a, T, B, D> Freeze for TensorMutable<'a, T, B, D>
where B: Freeze, D: Freeze, <D as DimBaseAPI>::Stride: Freeze, <B as DeviceRawAPI<T>>::Raw: Freeze,

§

impl<'a, T, B, D> RefUnwindSafe for TensorMutable<'a, T, B, D>

§

impl<'a, T, B, D> Send for TensorMutable<'a, T, B, D>
where B: Send, <B as DeviceRawAPI<T>>::Raw: Send, T: Send,

§

impl<'a, T, B, D> Sync for TensorMutable<'a, T, B, D>
where B: Sync, <B as DeviceRawAPI<T>>::Raw: Sync, T: Sync,

§

impl<'a, T, B, D> Unpin for TensorMutable<'a, T, B, D>
where B: Unpin, D: Unpin, <D as DimBaseAPI>::Stride: Unpin, <B as DeviceRawAPI<T>>::Raw: Unpin, T: Unpin,

§

impl<'a, T, B, D> !UnwindSafe for TensorMutable<'a, T, B, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ValWriteAPI<T> for T

Source§

fn write(&mut self, val: T) -> &mut T