pub struct TensorPool { /* private fields */ }Expand description
A thread-safe memory pool for tensor buffers.
The pool maintains separate storage for different buffer configurations and automatically grows as needed. Buffers are returned to the pool when dropped.
Implementations§
Source§impl TensorPool
impl TensorPool
Sourcepub fn with_capacity(max_buffers_per_key: usize) -> Self
pub fn with_capacity(max_buffers_per_key: usize) -> Self
Create a new tensor pool with specified maximum buffers per key.
Sourcepub fn acquire_f32(&self, key: BufferKey) -> InferenceResult<PooledBuffer<f32>>
pub fn acquire_f32(&self, key: BufferKey) -> InferenceResult<PooledBuffer<f32>>
Acquire a pooled f32 buffer.
Sourcepub fn acquire_f64(&self, key: BufferKey) -> InferenceResult<PooledBuffer<f64>>
pub fn acquire_f64(&self, key: BufferKey) -> InferenceResult<PooledBuffer<f64>>
Acquire a pooled f64 buffer.
Sourcepub fn clear(&self) -> InferenceResult<()>
pub fn clear(&self) -> InferenceResult<()>
Clear all pooled buffers.
Sourcepub fn stats(&self) -> InferenceResult<PoolStats>
pub fn stats(&self) -> InferenceResult<PoolStats>
Get pool statistics.
Sourcepub fn pooled_count(&self) -> InferenceResult<usize>
pub fn pooled_count(&self) -> InferenceResult<usize>
Get the current number of pooled buffers.
Trait Implementations§
Source§impl Clone for TensorPool
impl Clone for TensorPool
Source§fn clone(&self) -> TensorPool
fn clone(&self) -> TensorPool
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TensorPool
impl RefUnwindSafe for TensorPool
impl Send for TensorPool
impl Sync for TensorPool
impl Unpin for TensorPool
impl UnwindSafe for TensorPool
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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