pub struct MemoryPool<T> { /* private fields */ }Expand description
Memory pool for tensor allocation reuse
Implementations§
Source§impl<T> MemoryPool<T>
impl<T> MemoryPool<T>
pub fn new() -> Self
pub fn with_max_pool_size(self, max_size: usize) -> Self
Sourcepub fn acquire<F>(&mut self, size_class: usize, allocator: F) -> Twhere
F: FnOnce() -> T,
pub fn acquire<F>(&mut self, size_class: usize, allocator: F) -> Twhere
F: FnOnce() -> T,
Acquire a tensor from the pool or allocate new
Sourcepub fn total_pooled(&self) -> usize
pub fn total_pooled(&self) -> usize
Get total number of pooled tensors
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for MemoryPool<T>
impl<T> RefUnwindSafe for MemoryPool<T>where
T: RefUnwindSafe,
impl<T> Send for MemoryPool<T>where
T: Send,
impl<T> Sync for MemoryPool<T>where
T: Sync,
impl<T> Unpin for MemoryPool<T>where
T: Unpin,
impl<T> UnwindSafe for MemoryPool<T>where
T: 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