Skip to main content

ModuleRegistry

Struct ModuleRegistry 

Source
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

Source

pub const fn new() -> Self

Construct an empty registry in training mode.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn buffer_handle(&self, name: &str) -> Option<NamedBuffer>

Trait Implementations§

Source§

impl Default for ModuleRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for ModuleRegistry

§

impl !RefUnwindSafe for ModuleRegistry

§

impl !Send for ModuleRegistry

§

impl !Sync for ModuleRegistry

§

impl !UnwindSafe for ModuleRegistry

§

impl Forget for ModuleRegistry

§

impl Move for ModuleRegistry

§

impl Unpin for ModuleRegistry
where *const u8 is !null: Unpin, Rc<RefCell<ParameterState>>: Unpin, Rc<RefCell<Matrix>>: Unpin, Rc<Cell<u32>>: Unpin, Rc<RngStreamState>: Unpin, Rc<dyn Module>: Unpin,

§

impl UnsafeUnpin for ModuleRegistry
where *const u8 is !null: UnsafeUnpin, PhantomData<ParameterEntry>: UnsafeUnpin, PhantomData<BufferEntry>: UnsafeUnpin, PhantomData<StateU32Entry>: UnsafeUnpin, PhantomData<RngStateEntry>: UnsafeUnpin, PhantomData<ChildEntry>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.