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
impl Structure
pub fn def(&self, id: ModuleDefId) -> &ModuleDef
pub fn instance(&self, id: ModuleInstanceId) -> &ModuleInstance
pub fn site(&self, id: ParamSiteId) -> &ParamSite
pub fn add_def( &mut self, name: String, ctor: Option<String>, span: SrcSpan, ) -> ModuleDefId
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
Sourcepub fn derive_prefixes(&mut self)
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.
pub fn add_site( &mut self, owner: ModuleDefId, acquisition: Acquisition, relative_key: Key, kind: ParamKind, shape: Option<String>, span: SrcSpan, certainty: Certainty, ) -> ParamSiteId
pub fn add_param( &mut self, site: ParamSiteId, owner: ModuleInstanceId, key: Key, root: String, certainty: Certainty, ) -> ParamId
pub fn diagnose( &mut self, span: SrcSpan, message: impl Into<String>, key: Option<Key>, )
Sourcepub fn dedupe_params(&mut self)
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.