shrew/exec/
mod.rs

1// =============================================================================
2// Executor — Runs .sw programs on the Shrew tensor runtime
3// =============================================================================
4//
5// This module bridges the IR pipeline and the tensor runtime. It takes a
6// lowered, validated, optimized IrProgram and executes it:
7//
8//   .sw file → parse → lower → validate → optimize → **execute**
9//
10// The executor walks the computation graph in topological order, dispatching
11// each node's OpKind to the corresponding tensor operation, and manages
12// parameter initialization, forward passes, and training loops.
13//
14// USAGE:
15//   let program = shrew_ir::parse(source)?;
16//   let mut ir = shrew_ir::lower(&program)?;
17//   shrew_ir::validate(&ir)?;
18//   shrew_ir::infer_shapes(&mut ir);
19//   shrew_ir::optimize(&mut ir);
20//
21//   let mut exec = Executor::<CpuBackend>::new(ir, CpuDevice, RuntimeConfig::default())?;
22//   let outputs = exec.run("Forward", &inputs)?;
23
24mod engine;
25pub mod jit;
26mod train;
27
28pub use engine::{ExecResult, Executor, RuntimeConfig};
29pub use jit::{
30    compile_graph, load_jit, CompileStats, CompiledGraph, Instruction, JitExecutor, JitResult,
31    MemoryPlan,
32};
33pub use train::{load_program, load_trainer, EpochLog, TrainResult, Trainer};