Skip to main content

GraphSlot

Struct GraphSlot 

Source
pub struct GraphSlot {
    pub function: FunctionProto,
    pub op_dispatch: Vec<OpDispatch>,
    pub consumers: HashMap<NodeSiteId, Vec<OpRef>>,
    pub site_names: HashMap<String, NodeSiteId>,
    pub top_level_outputs: HashMap<NodeSiteId, String>,
    pub recv_sender_sites: HashMap<NodeSiteId, NodeSiteId>,
    pub recv_wire_type_hash: HashMap<NodeSiteId, u64>,
    pub recv_site_to_slot_id: HashMap<NodeSiteId, u32>,
    pub is_entry_point: bool,
}
Expand description

Per-FunctionProto compiled data installed on the Engine. Keyed in Engine.graphs by (domain, name, overload) - the canonical symbol-table key the linker dedupes on. The map key IS the name, so GraphSlot carries no separate name field.

Fields§

§function: FunctionProto

The post-analysis FunctionProto body. Source of truth for op_type / domain / input + output names. function.node[i] is the NodeProto for OpRef pack(graph_idx, i).

§op_dispatch: Vec<OpDispatch>

Per-NodeProto dispatch decision, indexed parallel to function.node[]. Populated by Engine::resolve_dispatch after install; runtime invoke is op_dispatch[node_idx] where node_idx = op_ref.split().1.

§consumers: HashMap<NodeSiteId, Vec<OpRef>>

Producer site → downstream consumer ops. Used by write_outputs to push ready consumers onto the frontier.

§site_names: HashMap<String, NodeSiteId>

Site name → NodeSiteId allocation.

§top_level_outputs: HashMap<NodeSiteId, String>

Top-level function.output sites, mapped from NodeSiteId to the declared output name. When a value lands at one of these sites and consumers[site] is empty, the engine surfaces it as EngineStep::AppEvent { module_name, topic: <output name> } — the “function signature is the engine I/O contract” path. Populated only for entry-point GraphSlots (is_entry_point).

§recv_sender_sites: HashMap<NodeSiteId, NodeSiteId>

wire.Recv payload site → sender site pairing. Recv NodeProtos emit two outputs — (payload, sender). The inbound envelope delivers its byte payload to the payload site; the engine also writes PeerIdValue(src_peer) to the sender site on the same execution so downstream user ops can read the provenance of the received message and reply by sending back to the same peer. Populated at install time by scanning every ai.bytesandbrains.wire Recv NodeProto with two outputs.

§recv_wire_type_hash: HashMap<NodeSiteId, u64>

wire.Recv payload site → expected wire-type hash. When the compiler stamped ValueInfoProto.type_node on a Recv’s payload output, the runtime carries the producer-side type_hash here so the typed-receive path can fire a WireReceiveError { kind: TypeMismatch } when an inbound fill’s type_hash does not match the slot contract. Slots without an entry are treated as dynamic / Any: the decoder-registry lookup proceeds without the mismatch check. Populated at install time alongside Self::recv_sender_sites.

§recv_site_to_slot_id: HashMap<NodeSiteId, u32>

wire.Recv payload site → bound role slot id. Built at install time by reading the compiler-stamped RECV_SLOT_ID_KEY off each wire.Recv NodeProto and pairing it with the Recv’s allocated NodeSiteId. Consumed by decode_typed_fill to cross from data-plane identity (NodeSiteId) to binding identity (slot_id) before dispatching the backend-mediated tensor path. Recv sites whose payload does not flow into a role-bound slot are absent.

§is_entry_point: bool

true if this function is an entry point (a registered Module’s main partition function). Entry-point GraphSlots have top_level_outputs populated; sub-function bodies do not (their outputs flow through CallContext.output_forwarding at call time).

Implementations§

Source§

impl GraphSlot

Source

pub fn from_function( _name: String, function: FunctionProto, graph_idx: u32, next_node_site_id: &mut u64, ) -> GraphSlot

Canonical install path: walks the FunctionProto’s nodes assigning positional OpRefs + fresh NodeSiteIds, populates op_index + site_names + consumers per docs/ENGINE.md §3.

OpRefs pack as (graph_idx << 32) | node_idx so the engine hot path resolves OpRef → NodeProto via two array accesses (the op_index HashMap is retained only as a /// migration aide; C8 deletes it). graph_idx is the engine’s number of already-installed graphs at the moment of install, passed in by the caller (typically Engine::install_graph / install_function_library). NodeSiteIds remain globally monotonic via next_node_site_id since they cross graphs.

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