pub struct InferenceEngine { /* private fields */ }Expand description
The main inference engine for AGSP
Implementations§
Source§impl InferenceEngine
impl InferenceEngine
Sourcepub fn new(config: EngineConfig) -> Self
pub fn new(config: EngineConfig) -> Self
Create a new inference engine without a model
Sourcepub fn with_model(
config: EngineConfig,
model: Box<dyn AutoregressiveModel>,
) -> Self
pub fn with_model( config: EngineConfig, model: Box<dyn AutoregressiveModel>, ) -> Self
Create a new inference engine with a model
Sourcepub fn set_model(&mut self, model: Box<dyn AutoregressiveModel>)
pub fn set_model(&mut self, model: Box<dyn AutoregressiveModel>)
Set the model for this engine
This will update the context configuration to match the model’s architecture
Sourcepub fn step(&mut self, input: &Array1<f32>) -> InferenceResult<Array1<f32>>
pub fn step(&mut self, input: &Array1<f32>) -> InferenceResult<Array1<f32>>
Perform a single inference step
This is the core autoregressive prediction: Given input x_t, predict x_{t+1}
Sourcepub fn rollout(
&mut self,
input: &Array1<f32>,
steps: usize,
) -> InferenceResult<Vec<Array1<f32>>>
pub fn rollout( &mut self, input: &Array1<f32>, steps: usize, ) -> InferenceResult<Vec<Array1<f32>>>
Perform multi-step rollout
Predicts steps future values autoregressively
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
Get the current step count
Sourcepub fn config(&self) -> &EngineConfig
pub fn config(&self) -> &EngineConfig
Get the configuration
Sourcepub fn context(&self) -> &InferenceContext
pub fn context(&self) -> &InferenceContext
Get the context
Sourcepub fn sampler_mut(&mut self) -> &mut Sampler
pub fn sampler_mut(&mut self) -> &mut Sampler
Get mutable access to the sampler
Sourcepub fn step_batch(
&mut self,
inputs: &[Array1<f32>],
) -> InferenceResult<Vec<Array1<f32>>>
pub fn step_batch( &mut self, inputs: &[Array1<f32>], ) -> InferenceResult<Vec<Array1<f32>>>
Perform batched inference on multiple inputs
This processes multiple inputs in parallel for efficiency. Each input is processed independently with its own hidden state.
Sourcepub fn model_info(&self) -> Option<ModelInfo>
pub fn model_info(&self) -> Option<ModelInfo>
Get model information
Auto Trait Implementations§
impl Freeze for InferenceEngine
impl !RefUnwindSafe for InferenceEngine
impl Send for InferenceEngine
impl !Sync for InferenceEngine
impl Unpin for InferenceEngine
impl !UnwindSafe for InferenceEngine
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