pub struct ModuleRegistry { /* private fields */ }Expand description
Constructor-owned structural registry for one Module.
Registration requires &mut self, so a module’s parameter/buffer/child tree
is fixed before the module is shared through Rc.
Implementations§
Source§impl ModuleRegistry
impl ModuleRegistry
Sourcepub fn register_parameter(
&mut self,
name: impl Into<String>,
parameter: Parameter,
) -> Result<()>
pub fn register_parameter( &mut self, name: impl Into<String>, parameter: Parameter, ) -> Result<()>
Register one direct parameter.
§Errors
Returns an error for an invalid/duplicate local name or when the same parameter handle is already registered directly.
Sourcepub fn register_buffer(
&mut self,
name: impl Into<String>,
data: Matrix,
persistent: bool,
) -> Result<()>
pub fn register_buffer( &mut self, name: impl Into<String>, data: Matrix, persistent: bool, ) -> Result<()>
Register one direct non-trainable buffer.
§Errors
Returns an error for an invalid/duplicate local name or duplicate semantic Matrix value.
Sourcepub fn register_state_u32(
&mut self,
name: impl Into<String>,
value: u32,
) -> Result<NamedStateU32>
pub fn register_state_u32( &mut self, name: impl Into<String>, value: u32, ) -> Result<NamedStateU32>
Register one direct persistent u32 scalar state value.
This is for compact host metadata whose value changes the next operation, such as an EMA transition counter. Bulk numerical state remains a Matrix buffer.
§Errors
Returns an error for an invalid or duplicate local name.
Sourcepub fn register_rng_state(
&mut self,
name: impl Into<String>,
initial_draw: u64,
) -> Result<NamedRngState>
pub fn register_rng_state( &mut self, name: impl Into<String>, initial_draw: u64, ) -> Result<NamedRngState>
Register one direct stochastic RNG draw stream for exact run-state resume.
Unlike Self::register_state_u32, RNG streams are excluded from .oam
model artifacts and persisted only in .runstate companion files.
§Errors
Returns an error for an invalid or duplicate local name.
Sourcepub fn attach_parameter(
&mut self,
path: impl Into<String>,
parameter: Parameter,
) -> Result<()>
pub fn attach_parameter( &mut self, path: impl Into<String>, parameter: Parameter, ) -> Result<()>
Attach an existing Parameter under a local or dotted path.
Intended for dynamic composition adapters (such as the Python Module
bridge) that flatten a validated module tree into one registry while
preserving each entry’s dotted path.
§Errors
Returns an error for an invalid dotted path, duplicate name, or duplicate parameter identity.
Sourcepub fn attach_buffer(
&mut self,
path: impl Into<String>,
buffer: NamedBuffer,
) -> Result<()>
pub fn attach_buffer( &mut self, path: impl Into<String>, buffer: NamedBuffer, ) -> Result<()>
Attach an existing live NamedBuffer under a local or dotted path.
Mutations applied through checkpoint loading update the original buffer’s
Rc<RefCell<Matrix>> in place.
§Errors
Returns an error for an invalid dotted path, duplicate name, or duplicate semantic Matrix buffer.
Sourcepub fn attach_buffer_matrix(
&mut self,
path: impl Into<String>,
data: Matrix,
persistent: bool,
) -> Result<NamedBuffer>
pub fn attach_buffer_matrix( &mut self, path: impl Into<String>, data: Matrix, persistent: bool, ) -> Result<NamedBuffer>
Attach a Matrix buffer under a local or dotted path and return its live
NamedBuffer handle so callers can observe replacements after load.
§Errors
Returns an error for an invalid dotted path, duplicate name, or duplicate semantic Matrix buffer.
Sourcepub fn attach_rng_state(
&mut self,
path: impl Into<String>,
state: NamedRngState,
) -> Result<()>
pub fn attach_rng_state( &mut self, path: impl Into<String>, state: NamedRngState, ) -> Result<()>
Attach an existing NamedRngState under a local or dotted path.
Intended for dynamic composition adapters (such as the Python Module
bridge) that assemble live RNG handles from child modules into one flat
registry while keeping each stream’s dotted path intact.
§Errors
Returns an error when path is empty, contains empty or non-ASCII
segments, collides with an existing entry name, or attaches the same
live RNG stream more than once.
Sourcepub fn register_module(
&mut self,
name: impl Into<String>,
module: Rc<dyn Module>,
) -> Result<()>
pub fn register_module( &mut self, name: impl Into<String>, module: Rc<dyn Module>, ) -> Result<()>
Register one owned child handle.
The child immediately inherits this registry’s train/eval mode.
§Errors
Returns an error for an invalid/duplicate local name or when the same child handle is already registered directly.