Skip to main content

RecordState

Trait RecordState 

Source
pub trait RecordState:
    Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn state_flatten(&self, prefix: &str, out: &mut StateSink);
    fn state_unflatten(
        prefix: &str,
        src: &mut StateSource,
        device: &Device,
    ) -> Option<Self>;
}
Expand description

A type that can be flattened into named tensors and scalars and rebuilt from them.

Generated with #[derive(RecordState)]. The prefix threads the parameter identity (and any nested field path) through the recursion; leaves are named {prefix}.{field}.

Required Methods§

Source

fn state_flatten(&self, prefix: &str, out: &mut StateSink)

Flatten self into out, naming every leaf under prefix.

Source

fn state_unflatten( prefix: &str, src: &mut StateSource, device: &Device, ) -> Option<Self>

Rebuild a value from src, reading leaves named under prefix.

Returns None when a required leaf is absent. The derive uses StateSource::has_under to presence-test optional nested states, so an Option<Nested> field is None exactly when nothing was recorded under its path.

A scalar leaf that is present but holds an incompatible Scalar variant (e.g. a hand-edited or forward-version file) is treated the same as absent.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl RecordState for ()

The empty state — for stateless values (e.g. a constant learning rate scheduler).

Source§

fn state_flatten(&self, _prefix: &str, _out: &mut StateSink)

Source§

fn state_unflatten( _prefix: &str, _src: &mut StateSource, _device: &Device, ) -> Option<Self>

Implementors§

Source§

impl RecordState for CosineAnnealingLrSchedulerState

Available on crate feature std only.
Source§

impl RecordState for ExponentialLrSchedulerState

Available on crate feature std only.
Source§

impl RecordState for LBFGSState

Source§

impl RecordState for LinearLrSchedulerState

Available on crate feature std only.
Source§

impl RecordState for NoamLrSchedulerState

Available on crate feature std only.
Source§

impl RecordState for StepLrSchedulerState

Available on crate feature std only.
Source§

impl<const D: usize> RecordState for AdaGradState<D>

Source§

impl<const D: usize> RecordState for AdamState<D>

Source§

impl<const D: usize> RecordState for AdamWState<D>

Source§

impl<const D: usize> RecordState for AdanState<D>

Source§

impl<const D: usize> RecordState for AdaptiveMomentumState<D>

Source§

impl<const D: usize> RecordState for AdaptiveNesterovMomentumState<D>

Source§

impl<const D: usize> RecordState for CenteredState<D>

Source§

impl<const D: usize> RecordState for LrDecayState<D>

Source§

impl<const D: usize> RecordState for MomentumState<D>

Source§

impl<const D: usize> RecordState for MuonState<D>

Source§

impl<const D: usize> RecordState for RmsPropMomentumState<D>

Source§

impl<const D: usize> RecordState for RmsPropState<D>

Source§

impl<const D: usize> RecordState for SgdState<D>

Source§

impl<const D: usize> RecordState for SquareAvgState<D>

Source§

impl<const D: usize> RecordState for WeightDecayState<D>