pub struct InferenceContext { /* private fields */ }Expand description
Manages inference context including history and hidden states
Implementations§
Source§impl InferenceContext
impl InferenceContext
Sourcepub fn new(config: ContextConfig) -> Self
pub fn new(config: ContextConfig) -> Self
Create a new inference context
Sourcepub fn with_pool(config: ContextConfig, pool: TensorPool) -> Self
pub fn with_pool(config: ContextConfig, pool: TensorPool) -> Self
Create a new inference context with memory pooling enabled
Sourcepub fn pool(&self) -> Option<&TensorPool>
pub fn pool(&self) -> Option<&TensorPool>
Get reference to the memory pool if available
Sourcepub fn enable_pooling(&mut self, pool: TensorPool)
pub fn enable_pooling(&mut self, pool: TensorPool)
Enable memory pooling with specified pool
Sourcepub fn disable_pooling(&mut self)
pub fn disable_pooling(&mut self)
Disable memory pooling
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
Get the current step count
Sourcepub fn history_len(&self) -> usize
pub fn history_len(&self) -> usize
Get the history length
Sourcepub fn states(&self) -> &[HiddenState]
pub fn states(&self) -> &[HiddenState]
Get hidden states
Sourcepub fn states_mut(&mut self) -> &mut [HiddenState]
pub fn states_mut(&mut self) -> &mut [HiddenState]
Get mutable hidden states
Sourcepub fn update_state(
&mut self,
layer: usize,
state: HiddenState,
) -> InferenceResult<()>
pub fn update_state( &mut self, layer: usize, state: HiddenState, ) -> InferenceResult<()>
Update hidden state for a layer
Sourcepub fn config(&self) -> &ContextConfig
pub fn config(&self) -> &ContextConfig
Get configuration
Sourcepub fn trim_history(&mut self, max_len: usize)
pub fn trim_history(&mut self, max_len: usize)
Trim history to specified length (for memory efficiency)
Auto Trait Implementations§
impl Freeze for InferenceContext
impl RefUnwindSafe for InferenceContext
impl Send for InferenceContext
impl Sync for InferenceContext
impl Unpin for InferenceContext
impl UnwindSafe for InferenceContext
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> 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