Skip to main content

Structure

Struct Structure 

Source
pub struct Structure {
    pub defs: Vec<ModuleDef>,
    pub instances: Vec<ModuleInstance>,
    pub sites: Vec<ParamSite>,
    pub params: Vec<Param>,
    pub root: Option<ModuleInstanceId>,
    pub diagnostics: Vec<Diagnostic>,
}

Fields§

§defs: Vec<ModuleDef>§instances: Vec<ModuleInstance>§sites: Vec<ParamSite>§params: Vec<Param>§root: Option<ModuleInstanceId>§diagnostics: Vec<Diagnostic>

Implementations§

Source§

impl Structure

Source

pub fn def(&self, id: ModuleDefId) -> &ModuleDef

Source

pub fn instance(&self, id: ModuleInstanceId) -> &ModuleInstance

Source

pub fn site(&self, id: ParamSiteId) -> &ParamSite

Source

pub fn add_def( &mut self, name: String, ctor: Option<String>, span: SrcSpan, ) -> ModuleDefId

Source

pub fn add_instance( &mut self, def: ModuleDefId, parent: Option<ModuleInstanceId>, via_field: Option<String>, prefix: Key, root: String, prefix_derived: bool, repeat: Option<Repeat>, origin: SrcSpan, certainty: Certainty, ) -> ModuleInstanceId

Source

pub fn derive_prefixes(&mut self)

Fill in the prefixes of grouping instances as the longest common prefix of everything beneath them. Runs bottom-up so nested grouping nodes resolve correctly.

Keys are grouped by VarBuilder root first, because distinct roots are distinct namespaces: a Layer holding both frozen base weights and a trainable cross-attention adapter has no meaningful prefix spanning the two, and computing one across them would collapse to empty and lose the grouping entirely. The most populated root wins, and the derived prefix is reported as belonging to it.

Source

pub fn add_site( &mut self, owner: ModuleDefId, acquisition: Acquisition, relative_key: Key, kind: ParamKind, shape: Option<String>, span: SrcSpan, certainty: Certainty, ) -> ParamSiteId

Source

pub fn add_param( &mut self, site: ParamSiteId, owner: ModuleInstanceId, key: Key, root: String, certainty: Certainty, ) -> ParamId

Source

pub fn diagnose( &mut self, span: SrcSpan, message: impl Into<String>, key: Option<Key>, )

Source

pub fn dedupe_params(&mut self)

Collapse parameters that resolve to the same tensor.

Branches produce duplicates: if cfg.attention_bias { linear(..) } else { linear_no_bias(..) } yields weight from both arms. When duplicates disagree about certainty the least certain wins, because the analyzer does not track which arms are mutually exclusive and must not claim more than it can prove.

Source

pub fn roots(&self) -> Vec<String>

Distinct VarBuilder roots in declaration order.

Source

pub fn coverage(&self) -> Coverage

Trait Implementations§

Source§

impl Debug for Structure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Structure

Source§

fn default() -> Structure

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

impl Serialize for Structure

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.