Skip to main content

BackendProvider

Trait BackendProvider 

Source
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§

Source

type ModelConfig

Portable model preparation request.

Source

type Model

Opaque backend model/executable.

Source

type Session: BackendSession<Self>

Opaque backend session/cache state and execution implementation.

Source

type Error: Error + Send + Sync + 'static

Backend error.

Required Methods§

Source

fn descriptor(&self) -> BackendDescriptor

Backend identity.

Source

fn devices( &self, ) -> Result<Vec<(DeviceDescriptor, DeviceCapabilities)>, Self::Error>

Discovers devices and their fail-closed capabilities.

Source

fn prepare_model( &self, config: Self::ModelConfig, ) -> Result<PreparedModel<Self::Model>, Self::Error>

Loads, compiles, or materializes a model for this backend.

Source

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§

Source

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".

Implementors§