Skip to main content

TypeSolver

Struct TypeSolver 

Source
pub struct TypeSolver { /* private fields */ }
Expand description

Bipartite type-resolution solver.

Implementations§

Source§

impl TypeSolver

Source

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).

Source

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>).

Source

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.

Source

pub fn solve(self) -> Result<TypeSolution, TypeError>

Run the worklist to fixpoint, then post-check that every slot resolved to a concrete leaf.

Source

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.

Source

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.

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<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<T> ErasedComponent for T
where T: Any + Send + Sync,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more