pub struct BufferPool { /* private fields */ }Expand description
Typed buffer pool keyed by element capacity and separated by scalar type.
Each supported dtype has an independent best-fit pool. Acquired buffers are returned without zero-initialization so GEMM callers can avoid redundant writes when they fully overwrite the output.
§Examples
ⓘ
use tenferro_tensor::buffer_pool::{BufferPool, PoolScalar};
let mut pool = BufferPool::new();
let buf = unsafe { <f32 as PoolScalar>::pool_acquire(&mut pool, 8) };
<f32 as PoolScalar>::pool_release(&mut pool, buf);
assert_eq!(pool.len(), 1);Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn acquire_with_capacity<T: PoolScalar>(&mut self, cap: usize) -> Vec<T>
pub fn acquire_with_capacity<T: PoolScalar>(&mut self, cap: usize) -> Vec<T>
Acquire a typed vector with length 0 and at least cap capacity.
Returned buffers come from the typed pool when possible and are ready for push-based population.
§Examples
ⓘ
use tenferro_tensor::buffer_pool::BufferPool;
let mut pool = BufferPool::new();
let mut buf = pool.acquire_with_capacity::<f64>(4);
buf.extend_from_slice(&[1.0, 2.0]);
assert_eq!(buf.len(), 2);
assert!(buf.capacity() >= 4);Trait Implementations§
Auto Trait Implementations§
impl Freeze for BufferPool
impl RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnsafeUnpin for BufferPool
impl UnwindSafe for BufferPool
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
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
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