pub trait ExecutionEngine: Engine {
// Required methods
fn target(&self) -> EngineTarget;
fn as_any_mut(&mut self) -> &mut dyn Any;
// Provided methods
fn take_extension_caches(&mut self) -> ExtensionCacheStore { ... }
fn restore_extension_caches(&mut self, caches: ExtensionCacheStore) { ... }
fn mark_broken(&mut self) { ... }
fn event_domain_driver(&self) -> Arc<dyn EventDomainDriver> ⓘ { ... }
fn retire_run(&mut self, run: Box<dyn EventDomainRun>) -> Result<()> { ... }
fn synchronize(&mut self) -> Result<()> { ... }
}Expand description
An engine the runtime can run prepared programs on.
Every operation runs on the Engine the caller passes in; this trait adds
what the scheduler needs from that engine: its target description, its own
extension caches, its event-domain driver and the hand-off point for device
work that is still running when a call returns. A CPU engine finishes its
work before returning, so the defaults (no caches, immediate events, drain
on hand-off) already describe it.
§Examples
use tenferro_runtime::{EngineTarget, ExecutionEngine};
fn describe(engine: &dyn ExecutionEngine) -> EngineTarget {
engine.target()
}Required Methods§
Sourcefn target(&self) -> EngineTarget
fn target(&self) -> EngineTarget
Immutable description used by crate::Runtime::prepare.
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Typed access for prepared operations that execute against the concrete
engine type instead of the Engine operations.
Provided Methods§
Sourcefn take_extension_caches(&mut self) -> ExtensionCacheStore
fn take_extension_caches(&mut self) -> ExtensionCacheStore
Move this engine’s extension caches out for the duration of one run.
The runtime calls Self::restore_extension_caches with the same store
when the run ends, on success and on error. The default keeps no caches.
Sourcefn restore_extension_caches(&mut self, caches: ExtensionCacheStore)
fn restore_extension_caches(&mut self, caches: ExtensionCacheStore)
Return the extension caches taken by Self::take_extension_caches.
Sourcefn mark_broken(&mut self)
fn mark_broken(&mut self)
Record that an extension callback panicked while the runtime had lent this engine’s extension caches to it.
The runtime restores the caches, calls this, and resumes the panic. An engine that tracks a broken state refuses later operations; the default keeps no such state.
Sourcefn event_domain_driver(&self) -> Arc<dyn EventDomainDriver> ⓘ
fn event_domain_driver(&self) -> Arc<dyn EventDomainDriver> ⓘ
The driver that opens this engine’s event-domain runs.
Host engines complete each launch before it returns, which the default immediate driver describes.
Sourcefn retire_run(&mut self, run: Box<dyn EventDomainRun>) -> Result<()>
fn retire_run(&mut self, run: Box<dyn EventDomainRun>) -> Result<()>
Take ownership of an event-domain run whose launches may still be running.
The runtime calls this after a run’s outputs have been collected. An engine that executes asynchronously keeps the run (and with it the memory its unfinished work uses) and retires it later; the default waits for it now.
§Errors
Returns the run’s typed crate::Error::Internal (or another
driver-defined event-domain error) when queued work reports a completion
failure or the native queue cannot be synchronized while it is retired.
Sourcefn synchronize(&mut self) -> Result<()>
fn synchronize(&mut self) -> Result<()>
Block until the work this engine queued has completed.
crate::Runtime::run returns as soon as an asynchronous engine has
queued the work; crate::Runtime::warm_up calls this afterwards, so a
caller can pay a program’s first execution at a moment it chooses. Host
engines complete every launch before it returns, which the default
describes.
§Errors
Returns crate::Error::TensorRuntime when the engine reports that
queued work failed or that the device cannot be synchronized.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".