pub struct ParallelModule<First, Second> { /* private fields */ }Expand description
Parallel composition of two modules
Trait Implementations§
Source§impl<First: Module, Second: Module> Module for ParallelModule<First, Second>
impl<First: Module, Second: Module> Module for ParallelModule<First, Second>
Source§fn parameters(&self) -> HashMap<String, Parameter>
fn parameters(&self) -> HashMap<String, Parameter>
Get all parameters in the module (non-recursive) Read more
Source§fn set_training(&mut self, training: bool)
fn set_training(&mut self, training: bool)
Set training mode (internal implementation) Read more
Source§fn named_parameters(&self) -> HashMap<String, Parameter>
fn named_parameters(&self) -> HashMap<String, Parameter>
Get named parameters (non-recursive) Read more
Source§fn all_parameters(&self) -> HashMap<String, Parameter>
fn all_parameters(&self) -> HashMap<String, Parameter>
Get all parameters recursively including submodules Read more
Source§fn all_named_parameters(&self) -> HashMap<String, Parameter>
fn all_named_parameters(&self) -> HashMap<String, Parameter>
Get all named parameters recursively with module prefixes Read more
Source§fn load_state_dict(
&mut self,
state_dict: &HashMap<String, Tensor>,
strict: bool,
) -> Result<()>
fn load_state_dict( &mut self, state_dict: &HashMap<String, Tensor>, strict: bool, ) -> Result<()>
Load state dictionary into the module Read more
Source§fn load_state_dict_strict(
&mut self,
state_dict: &HashMap<String, Tensor>,
) -> Result<()>
fn load_state_dict_strict( &mut self, state_dict: &HashMap<String, Tensor>, ) -> Result<()>
Load state dictionary with default strict=true
Source§fn name(&self) -> Option<&str>
fn name(&self) -> Option<&str>
Get the module name (optional, for debugging and serialization)
Source§fn named_children(&self) -> Vec<(String, &dyn Module)>
fn named_children(&self) -> Vec<(String, &dyn Module)>
Get all direct child modules with names Read more
Source§fn modules(&self) -> Vec<&dyn Module>where
Self: Sized,
fn modules(&self) -> Vec<&dyn Module>where
Self: Sized,
Get all modules recursively (depth-first traversal)
Source§fn named_modules(&self) -> Vec<(String, &dyn Module)>where
Self: Sized,
fn named_modules(&self) -> Vec<(String, &dyn Module)>where
Self: Sized,
Get all modules recursively with hierarchical names
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Count total number of parameters
Source§fn num_trainable_parameters(&self) -> usize
fn num_trainable_parameters(&self) -> usize
Count trainable parameters
Source§fn memory_usage(&self) -> usize
fn memory_usage(&self) -> usize
Get memory usage estimate in bytes
Source§fn extra_repr(&self) -> String
fn extra_repr(&self) -> String
Get string representation
Source§fn register_hook(
&mut self,
_hook_type: HookType,
_callback: HookCallback,
) -> Option<HookHandle>
fn register_hook( &mut self, _hook_type: HookType, _callback: HookCallback, ) -> Option<HookHandle>
Register a hook for this module (default implementation does nothing)
Source§fn remove_hook(&mut self, _hook_type: HookType, _handle: HookHandle) -> bool
fn remove_hook(&mut self, _hook_type: HookType, _handle: HookHandle) -> bool
Remove a hook by handle (default implementation does nothing)
Source§fn execute_hooks(
&self,
_hook_type: HookType,
_input: &Tensor,
_output: Option<&Tensor>,
) -> Result<()>
fn execute_hooks( &self, _hook_type: HookType, _input: &Tensor, _output: Option<&Tensor>, ) -> Result<()>
Execute hooks of a specific type (default implementation does nothing)
Source§fn forward_with_hooks(&self, input: &Tensor) -> Result<Tensor>
fn forward_with_hooks(&self, input: &Tensor) -> Result<Tensor>
Forward pass with hooks support
Source§fn call(&self, input: &Tensor) -> Result<Tensor>
fn call(&self, input: &Tensor) -> Result<Tensor>
Convenient method to call forward and handle common patterns Read more
Source§fn apply(&self, input: &Tensor) -> Result<Tensor>
fn apply(&self, input: &Tensor) -> Result<Tensor>
Apply the module to input (alias for forward) Read more
Source§fn has_parameters(&self) -> bool
fn has_parameters(&self) -> bool
Check if the module has any parameters
Source§fn has_children(&self) -> bool
fn has_children(&self) -> bool
Check if the module has any child modules
Source§fn parameter_count(&self) -> usize
fn parameter_count(&self) -> usize
Get parameter count (convenience method)
Source§fn trainable_parameter_count(&self) -> usize
fn trainable_parameter_count(&self) -> usize
Get trainable parameter count (convenience method)
Source§fn memory_usage_mb(&self) -> f64
fn memory_usage_mb(&self) -> f64
Get memory usage in MB (convenience method)
Source§fn toggle_training(&mut self)
fn toggle_training(&mut self)
Toggle training mode (convenience method)
Source§fn sequential_forward(modules: &[&dyn Module], input: Tensor) -> Result<Tensor>where
Self: Sized,
fn sequential_forward(modules: &[&dyn Module], input: Tensor) -> Result<Tensor>where
Self: Sized,
Sequential forward pass through multiple modules Read more
Source§fn batch_forward(&self, inputs: &[Tensor]) -> Result<Vec<Tensor>>
fn batch_forward(&self, inputs: &[Tensor]) -> Result<Vec<Tensor>>
Apply module multiple times with different inputs (batch processing) Read more
Source§fn conditional_forward(&self, input: &Tensor, condition: bool) -> Result<Tensor>
fn conditional_forward(&self, input: &Tensor, condition: bool) -> Result<Tensor>
Forward with condition - only apply if condition is true Read more
Source§fn residual_forward(&self, input: &Tensor) -> Result<Tensor>
fn residual_forward(&self, input: &Tensor) -> Result<Tensor>
Forward with residual connection Read more
Source§fn module_info(&self) -> ModuleInfo
fn module_info(&self) -> ModuleInfo
Get detailed module information for debugging Read more
Source§fn check_training_readiness(&self) -> Result<()>
fn check_training_readiness(&self) -> Result<()>
Check if module is ready for training Read more
Source§fn parameter_names_matching(&self, pattern: &str) -> Vec<String>
fn parameter_names_matching(&self, pattern: &str) -> Vec<String>
Get parameter names matching a pattern Read more
Source§fn parameters_by_type(&self, param_type: &str) -> HashMap<String, Parameter>
fn parameters_by_type(&self, param_type: &str) -> HashMap<String, Parameter>
Get parameters by layer type (e.g., “weight”, “bias”) Read more
Source§fn clone_parameters(&self) -> HashMap<String, Tensor>
fn clone_parameters(&self) -> HashMap<String, Tensor>
Clone module parameters (for creating copies or checkpoints) Read more
Source§fn diagnose(&self) -> ModuleDiagnostics
fn diagnose(&self) -> ModuleDiagnostics
Quick diagnostic check of module health Read more
Auto Trait Implementations§
impl<First, Second> Freeze for ParallelModule<First, Second>
impl<First, Second> RefUnwindSafe for ParallelModule<First, Second>where
First: RefUnwindSafe,
Second: RefUnwindSafe,
impl<First, Second> Send for ParallelModule<First, Second>
impl<First, Second> Sync for ParallelModule<First, Second>
impl<First, Second> Unpin for ParallelModule<First, Second>
impl<First, Second> UnsafeUnpin for ParallelModule<First, Second>where
First: UnsafeUnpin,
Second: UnsafeUnpin,
impl<First, Second> UnwindSafe for ParallelModule<First, Second>where
First: UnwindSafe,
Second: UnwindSafe,
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> 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 moreSource§impl<T> ModuleApply for Twhere
T: Module,
impl<T> ModuleApply for Twhere
T: Module,
Source§fn apply<F>(&mut self, f: &F) -> Result<(), TorshError>
fn apply<F>(&mut self, f: &F) -> Result<(), TorshError>
Apply a function to all submodules recursively
Source§fn apply_to_parameters<F>(&mut self, _f: &F) -> Result<(), TorshError>
fn apply_to_parameters<F>(&mut self, _f: &F) -> Result<(), TorshError>
Apply function to all parameters recursively
Source§fn apply_to_modules<F>(&mut self, _f: &F) -> Result<(), TorshError>
fn apply_to_modules<F>(&mut self, _f: &F) -> Result<(), TorshError>
Apply function to all modules recursively
Source§impl<T> ModuleComposition for Twhere
T: Module + 'static,
impl<T> ModuleComposition for Twhere
T: Module + 'static,
Source§fn then<Other>(self, other: Other) -> ComposedModule<T, Other>where
Other: Module + 'static,
fn then<Other>(self, other: Other) -> ComposedModule<T, Other>where
Other: Module + 'static,
Compose this module with another module sequentially Read more
Source§fn parallel<Other>(self, other: Other) -> ParallelModule<T, Other>where
Other: Module + 'static,
fn parallel<Other>(self, other: Other) -> ParallelModule<T, Other>where
Other: Module + 'static,
Compose this module with another module in parallel Read more
Source§fn residual(self) -> ResidualModule<T>
fn residual(self) -> ResidualModule<T>
Add a residual connection Read more
Source§fn conditional<F>(self, condition_fn: F) -> ConditionalModule<T, F>
fn conditional<F>(self, condition_fn: F) -> ConditionalModule<T, F>
Add conditional execution Read more
Source§impl<T> ModuleExt for T
impl<T> ModuleExt for T
Source§fn and_then<F>(&self, input: &Tensor, f: F) -> Result<Tensor>
fn and_then<F>(&self, input: &Tensor, f: F) -> Result<Tensor>
Chain forward pass with a transformation function Read more
Source§fn map<F>(&self, input: &Tensor, f: F) -> Result<Tensor>
fn map<F>(&self, input: &Tensor, f: F) -> Result<Tensor>
Apply module and map the output with a function Read more
Source§fn with_input<F>(&self, input: &Tensor, f: F) -> Result<Tensor>
fn with_input<F>(&self, input: &Tensor, f: F) -> Result<Tensor>
Forward pass with input transformation Read more
Source§fn print_summary(&self)
fn print_summary(&self)
Print module summary to stdout
Source§fn parameter_stats(&self) -> ParameterStats
fn parameter_stats(&self) -> ParameterStats
Get parameter statistics Read more
Source§fn has_finite_parameters(&self) -> bool
fn has_finite_parameters(&self) -> bool
Check if module has NaN or Inf in parameters Read more
Source§fn freeze_matching(&mut self, pattern: &str) -> usize
fn freeze_matching(&mut self, pattern: &str) -> usize
Freeze specific parameters by name pattern Read more
Source§fn unfreeze_matching(&mut self, pattern: &str) -> usize
fn unfreeze_matching(&mut self, pattern: &str) -> usize
Unfreeze specific parameters by name pattern Read more
Source§fn clone_state_dict(&self) -> HashMap<String, Tensor>
fn clone_state_dict(&self) -> HashMap<String, Tensor>
Clone module parameters into a new state dict Read more
Source§fn apply_to_parameters<F>(&self, f: F)
fn apply_to_parameters<F>(&self, f: F)
Apply a function to all parameters Read more