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
impl GraphSession
pub fn new(graph: Graph, library: FilterLibrary) -> Self
pub fn with_cache(self, cache: Arc<dyn CacheStore>) -> Self
pub fn with_event_bus(self, bus: Arc<EventBus>) -> Self
pub fn with_data_store(self, store: Arc<dyn DataStore>) -> Self
pub fn with_remote_executor(self, executor: Arc<dyn RemoteExecutor>) -> Self
Sourcepub fn compile(&self, mode: CompileMode) -> Result<CompileResult>
pub fn compile(&self, mode: CompileMode) -> Result<CompileResult>
Compile the graph and return diagnostics without executing.
Sourcepub fn run(&mut self, mode: CompileMode) -> Result<HashMap<String, Value>>
pub fn run(&mut self, mode: CompileMode) -> Result<HashMap<String, Value>>
Compile and execute the graph, returning all node outputs.
Sourcepub fn fit(
&mut self,
x: &Value,
y: Option<&Value>,
) -> Result<HashMap<String, Value>>
pub fn fit( &mut self, x: &Value, y: Option<&Value>, ) -> Result<HashMap<String, Value>>
Fit all trainable filters in topological order.
For each node in topo order:
- Resolve input from predecessors
- If trainable: call
fit(input, y), cache state, thenforward(input, state) - If stateless: call
forward(input, Empty) - Store output for downstream nodes
Sourcepub fn forward(&self, x: &Value) -> Result<Value>
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().
Sourcepub fn forward_batched(
&self,
data_ref: &DataRef,
batch_size: usize,
) -> Result<Value>
pub fn forward_batched( &self, data_ref: &DataRef, batch_size: usize, ) -> Result<Value>
Forward pass in batches from a DataStore reference.
Sourcepub fn persist_states(&self) -> Result<DataRef>
pub fn persist_states(&self) -> Result<DataRef>
Persist all trained states to the data store.
Sourcepub fn load_states(&mut self, data_ref: &DataRef) -> Result<()>
pub fn load_states(&mut self, data_ref: &DataRef) -> Result<()>
Load previously persisted states from a data store reference.
Sourcepub fn library(&self) -> &FilterLibrary
pub fn library(&self) -> &FilterLibrary
Access the filter library.
Sourcepub fn library_mut(&mut self) -> &mut FilterLibrary
pub fn library_mut(&mut self) -> &mut FilterLibrary
Mutable access to the filter library (for registering filters after creation).
Auto Trait Implementations§
impl Freeze for GraphSession
impl !RefUnwindSafe for GraphSession
impl Send for GraphSession
impl Sync for GraphSession
impl Unpin for GraphSession
impl UnsafeUnpin for GraphSession
impl !UnwindSafe for GraphSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more