Skip to main content

ModuleComposition

Trait ModuleComposition 

Source
pub trait ModuleComposition {
    // Required methods
    fn then<Other: Module + 'static>(
        self,
        other: Other,
    ) -> ComposedModule<Self, Other>
       where Self: Sized + 'static;
    fn parallel<Other: Module + 'static>(
        self,
        other: Other,
    ) -> ParallelModule<Self, Other>
       where Self: Sized + 'static;
    fn residual(self) -> ResidualModule<Self>
       where Self: Sized + 'static;
    fn conditional<F>(self, condition_fn: F) -> ConditionalModule<Self, F>
       where Self: Sized + 'static,
             F: Fn() -> bool + Send + Sync;
}
Expand description

Trait for modules that support functional composition

Required Methods§

Source

fn then<Other: Module + 'static>( self, other: Other, ) -> ComposedModule<Self, Other>
where Self: Sized + 'static,

Compose this module with another module sequentially

Creates a new module that applies self then other.

Source

fn parallel<Other: Module + 'static>( self, other: Other, ) -> ParallelModule<Self, Other>
where Self: Sized + 'static,

Compose this module with another module in parallel

Creates a new module that applies both modules to the same input and combines results.

Source

fn residual(self) -> ResidualModule<Self>
where Self: Sized + 'static,

Add a residual connection

Creates a new module that adds the input to the output of this module.

Source

fn conditional<F>(self, condition_fn: F) -> ConditionalModule<Self, F>
where Self: Sized + 'static, F: Fn() -> bool + Send + Sync,

Add conditional execution

Creates a new module that only applies this module when the condition is true.

Implementors§

Source§

impl<T: Module + 'static> ModuleComposition for T

Blanket implementation of ModuleComposition for all modules