pub struct TypeSolver { /* private fields */ }Expand description
Bipartite type-resolution solver.
Implementations§
Source§impl TypeSolver
impl TypeSolver
Sourcepub fn from_graph(
graph: &GraphProto,
decl_for_op: impl Fn(&str, &str) -> Option<&'static AtomicOpDecl>,
) -> Result<Self, TypeError>
pub fn from_graph( graph: &GraphProto, decl_for_op: impl Fn(&str, &str) -> Option<&'static AtomicOpDecl>, ) -> Result<Self, TypeError>
Build a fresh solver from a GraphProto. Walks every node,
allocates slots for every value name, instantiates relations
per the op’s AtomicOpDecl.type_relations.
decl_for_op lets the caller plug in their own
(domain, op_type) -> &AtomicOpDecl lookup (typically the
compiler’s registered opset catalog).
Sourcepub fn seed(&mut self, value: &str, node: &'static TypeNode)
pub fn seed(&mut self, value: &str, node: &'static TypeNode)
Seed a value’s type with a concrete (or narrower-than-Any)
TypeNode. Used by callers that know specific inputs’ types
upfront (e.g. an AppEvent feeding a Tensor<F32>).
Sourcepub fn seed_from_value_info(&mut self, graph: &GraphProto)
pub fn seed_from_value_info(&mut self, graph: &GraphProto)
Walk graph.input + graph.value_info and seed every value
whose ValueInfoProto.type.denotation maps to a built-in
TypeNode (via bb_ir::types::builtins::lookup_denotation).
Values with unknown denotations are left at TYPE_ANY; the
solver narrows them via relations during solve().
Per the architecture’s polymorphic-type contract, the DSL’s
Graph::input(name) records each input with the
ai.bytesandbrains.opaque denotation (→ TYPE_ANY). Wire
op outputs + framework-recorded values carry pinned
denotations the lookup recognizes; that pinning seeds the
solver with concrete-leaf TypeNodes from which the
relation network propagates.
Sourcepub fn solve(self) -> Result<TypeSolution, TypeError>
pub fn solve(self) -> Result<TypeSolution, TypeError>
Run the worklist to fixpoint, then post-check that every slot resolved to a concrete leaf.
Sourcepub fn apply_solution_to_value_info(
graph: &mut GraphProto,
solution: &TypeSolution,
)
pub fn apply_solution_to_value_info( graph: &mut GraphProto, solution: &TypeSolution, )
Stamp solution’s resolved TypeNodes back onto every
matching ValueInfoProto.type.denotation in graph.
Downstream passes + the runtime read the narrowed
denotation instead of the recorder’s
ai.bytesandbrains.opaque placeholder.
Unresolved (still-TYPE_ANY) entries are left as-is —
they keep their original denotation. Permissive mode
surfaces here as silent pass-through; strict mode is the
caller’s choice via solve_strict() BEFORE this is called.
Sourcepub fn solve_strict(self) -> Result<TypeSolution, TypeError>
pub fn solve_strict(self) -> Result<TypeSolution, TypeError>
Strict-mode solve: every slot MUST resolve to a concrete leaf.
Returns UnresolvedType on the first abstract slot.