pub struct BufferPool { /* private fields */ }Expand description
Reusable buffer pool for intermediate tensor allocations.
Tracks freed Vec<f64> and Vec<Complex64> buffers indexed by length.
When a contraction step completes, its input buffers are returned to the
pool. Subsequent steps can reuse these buffers instead of allocating fresh.
Uses BTreeMap so pool_acquire can find the smallest buffer ≥ requested
size (best-fit), improving reuse when intermediate sizes vary slightly.
§Usage
Create a pool and pass it to EinsumCode::evaluate_with_pool to reuse
buffers across multiple einsum calls:
ⓘ
let mut pool = BufferPool::new();
code.evaluate_with_pool(operands1, None, Some(&mut pool))?;
code.evaluate_with_pool(operands2, None, Some(&mut pool))?;Pass None to let each call allocate and free independently (no pooling).
Implementations§
Source§impl BufferPool
impl BufferPool
Auto Trait Implementations§
impl Freeze for BufferPool
impl RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin 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