pub trait IterativeKernel<S, I, O>: GpuKernel{
// Required methods
fn initial_state(&self, input: &I) -> S;
fn iterate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 mut S,
input: &'life2 I,
) -> Pin<Box<dyn Future<Output = Result<IterationResult<O>, KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn converged(&self, state: &S, threshold: f64) -> bool;
// Provided methods
fn max_iterations(&self) -> usize { ... }
fn default_threshold(&self) -> f64 { ... }
fn run_to_convergence<'life0, 'async_trait>(
&'life0 self,
input: I,
) -> Pin<Box<dyn Future<Output = Result<O, KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: Sync + 'async_trait { ... }
fn run_to_convergence_with_threshold<'life0, 'async_trait>(
&'life0 self,
input: I,
threshold: f64,
) -> Pin<Box<dyn Future<Output = Result<O, KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: Sync + 'async_trait { ... }
}Expand description
Trait for iterative (multi-pass) kernels.
Provides support for algorithms that require multiple iterations to converge (e.g., PageRank, K-Means).
§Type Parameters
S: State typeI: Input typeO: Output type
Required Methods§
Sourcefn initial_state(&self, input: &I) -> S
fn initial_state(&self, input: &I) -> S
Create the initial state.
Sourcefn iterate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 mut S,
input: &'life2 I,
) -> Pin<Box<dyn Future<Output = Result<IterationResult<O>, KernelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn iterate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 mut S,
input: &'life2 I,
) -> Pin<Box<dyn Future<Output = Result<IterationResult<O>, KernelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Provided Methods§
Sourcefn max_iterations(&self) -> usize
fn max_iterations(&self) -> usize
Maximum number of iterations.
Sourcefn default_threshold(&self) -> f64
fn default_threshold(&self) -> f64
Default convergence threshold.
Sourcefn run_to_convergence<'life0, 'async_trait>(
&'life0 self,
input: I,
) -> Pin<Box<dyn Future<Output = Result<O, KernelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn run_to_convergence<'life0, 'async_trait>(
&'life0 self,
input: I,
) -> Pin<Box<dyn Future<Output = Result<O, KernelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: Sync + 'async_trait,
Run the iterative algorithm to convergence.
Sourcefn run_to_convergence_with_threshold<'life0, 'async_trait>(
&'life0 self,
input: I,
threshold: f64,
) -> Pin<Box<dyn Future<Output = Result<O, KernelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn run_to_convergence_with_threshold<'life0, 'async_trait>(
&'life0 self,
input: I,
threshold: f64,
) -> Pin<Box<dyn Future<Output = Result<O, KernelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: Sync + 'async_trait,
Run the iterative algorithm with a custom threshold.