pub trait BackendProvider: Sized {
type ModelConfig;
type Model;
type Session: BackendSession<Self>;
type Error: Error + Send + Sync + 'static;
// Required methods
fn descriptor(&self) -> BackendDescriptor;
fn devices(
&self,
) -> Result<Vec<(DeviceDescriptor, DeviceCapabilities)>, Self::Error>;
fn prepare_model(
&self,
config: Self::ModelConfig,
) -> Result<PreparedModel<Self::Model>, Self::Error>;
fn create_session(
&self,
model: PreparedModel<Self::Model>,
) -> Result<Self::Session, Self::Error>;
// Provided method
fn session_capability_mismatch(
&self,
admitted: SessionCapabilities,
realized: SessionCapabilities,
) -> Self::Error { ... }
}Expand description
One backend selected for an entire prepared model and all its sessions.
Required Associated Types§
Sourcetype ModelConfig
type ModelConfig
Portable model preparation request.
Sourcetype Session: BackendSession<Self>
type Session: BackendSession<Self>
Opaque backend session/cache state and execution implementation.
Required Methods§
Sourcefn descriptor(&self) -> BackendDescriptor
fn descriptor(&self) -> BackendDescriptor
Backend identity.
Sourcefn devices(
&self,
) -> Result<Vec<(DeviceDescriptor, DeviceCapabilities)>, Self::Error>
fn devices( &self, ) -> Result<Vec<(DeviceDescriptor, DeviceCapabilities)>, Self::Error>
Discovers devices and their fail-closed capabilities.
Sourcefn prepare_model(
&self,
config: Self::ModelConfig,
) -> Result<PreparedModel<Self::Model>, Self::Error>
fn prepare_model( &self, config: Self::ModelConfig, ) -> Result<PreparedModel<Self::Model>, Self::Error>
Loads, compiles, or materializes a model for this backend.
Sourcefn create_session(
&self,
model: PreparedModel<Self::Model>,
) -> Result<Self::Session, Self::Error>
fn create_session( &self, model: PreparedModel<Self::Model>, ) -> Result<Self::Session, Self::Error>
Consumes a prepared model into one backend-owned execution session.
The executable and its mutable cache state have one owner after this call. This prevents callers from pairing session state with a different model or submitting the same mutable executable through two sessions.
Provided Methods§
Sourcefn session_capability_mismatch(
&self,
admitted: SessionCapabilities,
realized: SessionCapabilities,
) -> Self::Error
fn session_capability_mismatch( &self, admitted: SessionCapabilities, realized: SessionCapabilities, ) -> Self::Error
Constructs an internal backend error for an admission/realization mismatch.
Backends whose prepared and realized reports cannot differ may leave this unreachable default in place.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".