pub struct TchTensor<E>where
E: Element,{
pub tensor: Tensor,
pub storage: Storage,
/* private fields */
}
Expand description
A tensor using the tch backend.
Fields§
§tensor: Tensor
Handle to the tensor. Call methods on this field.
storage: Storage
The tensor’s storage
Implementations§
§impl<E> TchTensor<E>where
E: Element,
impl<E> TchTensor<E>where
E: Element,
pub fn new(tensor: Tensor) -> TchTensor<E>
pub fn new(tensor: Tensor) -> TchTensor<E>
Create a new tensor.
Note that if the tensor was created from an operation that may reuse the same tensor storage as the parent, you should use from_existing instead.
pub fn from_existing(tensor: Tensor, storage_parent: Storage) -> TchTensor<E>
pub fn from_existing(tensor: Tensor, storage_parent: Storage) -> TchTensor<E>
Create a tensor that was created from an operation executed on a parent tensor.
If the child tensor shared the same storage as its parent, it will be cloned, effectively tracking how much tensors point to the same memory space.
§impl<P> TchTensor<P>where
P: Element,
impl<P> TchTensor<P>where
P: Element,
pub fn can_mut(&self) -> bool
pub fn can_mut(&self) -> bool
Checks if the tensor can be mutated in-place.
Returns true
if the tensor’s stride does not contain zero (no broadcasting)
and the storage can be mutated.
pub fn mut_ops<F, EOut>(&mut self, func: F) -> Option<TchTensor<EOut>>where
F: Fn(&mut Tensor) -> Tensor,
EOut: Element,
pub fn mut_ops<F, EOut>(&mut self, func: F) -> Option<TchTensor<EOut>>where
F: Fn(&mut Tensor) -> Tensor,
EOut: Element,
Executes an operation on a tensor if the data can be reused.
pub fn unary_ops<FOwn, FRef, EOut>(
self,
fown: FOwn,
fref: FRef,
) -> TchTensor<EOut>
pub fn unary_ops<FOwn, FRef, EOut>( self, fown: FOwn, fref: FRef, ) -> TchTensor<EOut>
Executes a unary operation, reusing the tensor data if possible.
pub fn binary_ops_tensor<FLMut, FRMut, FRef, EOut>(
lhs: TchTensor<P>,
rhs: TchTensor<P>,
flmut: FLMut,
frmut: FRMut,
fref: FRef,
) -> TchTensor<EOut>
pub fn binary_ops_tensor<FLMut, FRMut, FRef, EOut>( lhs: TchTensor<P>, rhs: TchTensor<P>, flmut: FLMut, frmut: FRMut, fref: FRef, ) -> TchTensor<EOut>
Executes a binary operation, reusing the tensor data if possible.
§impl<E> TchTensor<E>
impl<E> TchTensor<E>
pub fn from_data(data: TensorData, device: Device) -> TchTensor<E>
pub fn from_data(data: TensorData, device: Device) -> TchTensor<E>
Trait Implementations§
impl<E> Send for TchTensor<E>where
E: Element,
impl<E> StructuralPartialEq for TchTensor<E>where
E: Element,
impl<E> Sync for TchTensor<E>where
E: Element,
Auto Trait Implementations§
impl<E> Freeze for TchTensor<E>
impl<E> RefUnwindSafe for TchTensor<E>where
E: RefUnwindSafe,
impl<E> Unpin for TchTensor<E>where
E: Unpin,
impl<E> UnwindSafe for TchTensor<E>where
E: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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