pub struct PooledTensor<T: TensorElement + Default> { /* private fields */ }Expand description
A pooled tensor that automatically returns memory to pool when dropped
Implementations§
Source§impl<T: TensorElement + Copy + Default> PooledTensor<T>
impl<T: TensorElement + Copy + Default> PooledTensor<T>
Sourcepub fn new(shape: &[usize], device: DeviceType) -> Result<Self>
pub fn new(shape: &[usize], device: DeviceType) -> Result<Self>
Create a new pooled tensor
Sourcepub fn zeros(shape: &[usize], device: DeviceType) -> Result<Self>
pub fn zeros(shape: &[usize], device: DeviceType) -> Result<Self>
Create pooled zeros tensor
Sourcepub fn ones(shape: &[usize], device: DeviceType) -> Result<Self>
pub fn ones(shape: &[usize], device: DeviceType) -> Result<Self>
Create pooled ones tensor
Sourcepub fn tensor_mut(&mut self) -> &mut Tensor<T>
pub fn tensor_mut(&mut self) -> &mut Tensor<T>
Get mutable reference to the underlying tensor
Sourcepub fn into_tensor(self) -> Tensor<T>
pub fn into_tensor(self) -> Tensor<T>
Convert to owned tensor (removes from pool management)
Trait Implementations§
Source§impl<T: Debug + TensorElement + Default> Debug for PooledTensor<T>
impl<T: Debug + TensorElement + Default> Debug for PooledTensor<T>
Source§impl<T: TensorElement + Default> Drop for PooledTensor<T>
impl<T: TensorElement + Default> Drop for PooledTensor<T>
Auto Trait Implementations§
impl<T> !Freeze for PooledTensor<T>
impl<T> RefUnwindSafe for PooledTensor<T>where
T: RefUnwindSafe,
impl<T> Send for PooledTensor<T>
impl<T> Sync for PooledTensor<T>
impl<T> Unpin for PooledTensor<T>where
T: Unpin,
impl<T> UnsafeUnpin for PooledTensor<T>
impl<T> UnwindSafe for PooledTensor<T>where
T: UnwindSafe + RefUnwindSafe,
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
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