pub struct TchTensor<E: Element, const D: usize> {
pub tensor: Tensor,
pub storage: Storage,
/* private fields */
}Expand description
A tensor that uses the tch backend.
Fields§
§tensor: TensorHandle to the tensor. Call methods on this field.
storage: StorageThe tensor’s storage
Implementations§
source§impl<E: Element, const D: usize> TchTensor<E, D>
impl<E: Element, const D: usize> TchTensor<E, D>
sourcepub fn new(tensor: Tensor) -> Self
pub fn new(tensor: Tensor) -> Self
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.
sourcepub fn from_existing(tensor: Tensor, storage_parent: Storage) -> Self
pub fn from_existing(tensor: Tensor, storage_parent: Storage) -> Self
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.
source§impl<P: Element, const D: usize> TchTensor<P, D>
impl<P: Element, const D: usize> TchTensor<P, D>
sourcepub fn mut_ops<F: Fn(&mut Tensor) -> Tensor, EOut: Element, const D_OUT: usize>(
&mut self,
func: F
) -> Option<TchTensor<EOut, D_OUT>>
pub fn mut_ops<F: Fn(&mut Tensor) -> Tensor, EOut: Element, const D_OUT: usize>( &mut self, func: F ) -> Option<TchTensor<EOut, D_OUT>>
Execute an operation on a tensor if the data can be reused.
sourcepub fn unary_ops<FOwn, FRef, EOut: Element, const D_OUT: usize>(
self,
fown: FOwn,
fref: FRef
) -> TchTensor<EOut, D_OUT>
pub fn unary_ops<FOwn, FRef, EOut: Element, const D_OUT: usize>( self, fown: FOwn, fref: FRef ) -> TchTensor<EOut, D_OUT>
Execute a unary ops reusing the tensor data if possible.
sourcepub fn binary_ops_tensor<FLMut, FRMut, FRef, EOut: Element, const D_OUT: usize>(
lhs: Self,
rhs: Self,
flmut: FLMut,
frmut: FRMut,
fref: FRef
) -> TchTensor<EOut, D_OUT>
pub fn binary_ops_tensor<FLMut, FRMut, FRef, EOut: Element, const D_OUT: usize>( lhs: Self, rhs: Self, flmut: FLMut, frmut: FRMut, fref: FRef ) -> TchTensor<EOut, D_OUT>
Execute a binary ops reusing the tensor data if possible.
Trait Implementations§
source§impl<E: PartialEq + Element, const D: usize> PartialEq for TchTensor<E, D>
impl<E: PartialEq + Element, const D: usize> PartialEq for TchTensor<E, D>
impl<E: Element, const D: usize> Send for TchTensor<E, D>
impl<E: Element, const D: usize> StructuralPartialEq for TchTensor<E, D>
impl<E: Element, const D: usize> Sync for TchTensor<E, D>
Auto Trait Implementations§
impl<E, const D: usize> Freeze for TchTensor<E, D>
impl<E, const D: usize> RefUnwindSafe for TchTensor<E, D>where
E: RefUnwindSafe,
impl<E, const D: usize> Unpin for TchTensor<E, D>where
E: Unpin,
impl<E, const D: usize> UnwindSafe for TchTensor<E, D>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
Mutably borrows from an owned value. Read more