Skip to main content

GraphSession

Struct GraphSession 

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

The primary orchestrator: Graph + filters + cache + events.

let mut lib = FilterLibrary::new();
lib.register("scaler", Box::new(MyScaler::new()));
lib.register("model", Box::new(MyModel::new()));

let mut session = GraphSession::new(graph, lib);
session.fit(&train_x, Some(&train_y))?;
let output = session.forward(&test_x)?;

Implementations§

Source§

impl GraphSession

Source

pub fn new(graph: Graph, library: FilterLibrary) -> Self

Source

pub fn with_cache(self, cache: Arc<dyn CacheStore>) -> Self

Source

pub fn with_event_bus(self, bus: Arc<EventBus>) -> Self

Source

pub fn with_data_store(self, store: Arc<dyn DataStore>) -> Self

Source

pub fn with_transport(self, transport: Arc<dyn Transport>) -> Self

Source

pub fn compile(&self, mode: CompileMode) -> Result<CompileResult>

Compile the graph and return diagnostics without executing.

Source

pub fn run(&mut self, mode: CompileMode) -> Result<HashMap<String, Value>>

Compile and execute the graph, returning all node outputs.

Source

pub fn fit( &mut self, x: &Value, y: Option<&Value>, ) -> Result<HashMap<String, Value>>

Fit all trainable filters in topological order. Delegates to LocalRunner — same execution path as remote workers.

Source

pub fn forward(&self, x: &Value) -> Result<Value>

Forward pass through the fitted graph (inference).

Compiles in Inference mode and executes. Trainable filters use states cached during fit(). Forward pass through the fitted graph (inference). Delegates to LocalRunner — same execution path as remote workers.

Source

pub fn forward_batched( &self, data_ref: &DataRef, batch_size: usize, ) -> Result<Value>

Forward pass in batches from a DataStore reference.

Source

pub fn persist_states(&self) -> Result<DataRef>

Persist all trained states to the data store.

Source

pub fn load_states(&mut self, data_ref: &DataRef) -> Result<()>

Load previously persisted states from a data store reference.

Source

pub fn subscribe(&self) -> Receiver<Event>

Subscribe to execution events.

Source

pub fn event_bus(&self) -> &Arc<EventBus>

Access the event bus directly.

Source

pub fn is_fitted(&self) -> bool

Whether the session has been fitted.

Source

pub fn graph(&self) -> &Graph

Access the graph.

Source

pub fn library(&self) -> &FilterLibrary

Access the filter library.

Source

pub fn library_mut(&mut self) -> &mut FilterLibrary

Mutable access to the filter library (for registering filters after creation).

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

Source§

type Output = T

Should always be Self
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