pub struct Simulator { /* private fields */ }Expand description
High-level entry point for validating and executing a graph.
Implementations§
Source§impl Simulator
impl Simulator
Sourcepub fn new(model: &ModelLoader, graph: &Graph, device: Device) -> Result<Self>
pub fn new(model: &ModelLoader, graph: &Graph, device: Device) -> Result<Self>
Create a new simulator for a graph and model on a device.
This validates the graph, initializes the op registry, and warms kernels for the chosen device.
§Example
let model = ModelLoader::open("model.oinf")?;
let g = graph! { block entry { return; } };
let sim = Simulator::new(&model, &g, Device::Cpu)?;
let _exec = sim.make_executor()?;Sourcepub fn with_trace(self) -> Self
pub fn with_trace(self) -> Self
Enable execution tracing for the next executor.
Sourcepub fn with_timer(self) -> Self
pub fn with_timer(self) -> Self
Enable timing capture for the next executor.
Sourcepub fn make_executor(&self) -> Result<Executor>
pub fn make_executor(&self) -> Result<Executor>
Build an executor with the current simulator configuration.
§Example
let model = ModelLoader::open("model.oinf")?;
let g = graph! { block entry { return; } };
let sim = Simulator::new(&model, &g, Device::Cpu)?;
let mut exec = sim.make_executor()?;
exec.step()?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for Simulator
impl RefUnwindSafe for Simulator
impl Send for Simulator
impl Sync for Simulator
impl Unpin for Simulator
impl UnwindSafe for Simulator
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more