pub enum ExecutionProvider {
Cpu,
Auto,
DirectMl,
CoreMl,
}Expand description
Where inference runs.
Cpu is the default. Auto registers the platform accelerator (DirectML
on Windows, CoreML on macOS) and falls back to CPU, with the reason
recorded, when registration, model load, the probe inference or the vector
parity check fails. DirectMl / CoreMl request that accelerator
explicitly and fail loudly instead of falling back: a failed parity check
is EmbedError::AcceleratorParity.
An accelerator is used only if it reproduces the CPU provider’s vectors.
Whenever the session was built on anything other than CPU, Embedder::load
builds a CPU session for the same model, embeds fixed short, medium and
long prompts (alone and as one batch) through both sessions with the
crate’s real inference path, and requires every pair to have cosine
similarity of at least ACCELERATOR_PARITY_MIN_COSINE on the full
native-dimension vector, with finite non-zero output. On success the CPU
session is dropped before load returns, so steady-state memory is
unchanged; the check costs one extra CPU session build and a few inferences
at load. Cpu does none of this. The check cannot be turned off.
Measured: DirectML (ONNX Runtime 1.24.4) returns wrong EmbeddingGemma 2 Q4 vectors (cosine to CPU 0.58-0.72) that are finite, non-zero and faster than CPU, so a probe or speed check alone would accept them. CoreML is unmeasured; it must pass the same check.
Variants§
Trait Implementations§
Source§impl Clone for ExecutionProvider
impl Clone for ExecutionProvider
impl Copy for ExecutionProvider
Source§impl Debug for ExecutionProvider
impl Debug for ExecutionProvider
Source§impl Default for ExecutionProvider
impl Default for ExecutionProvider
impl Eq for ExecutionProvider
Source§impl From<ExecutionProvider> for ExecutionProvider
impl From<ExecutionProvider> for ExecutionProvider
Source§fn from(value: ExecutionProvider) -> Self
fn from(value: ExecutionProvider) -> Self
Source§impl PartialEq for ExecutionProvider
impl PartialEq for ExecutionProvider
impl StructuralPartialEq for ExecutionProvider
Auto Trait Implementations§
impl Freeze for ExecutionProvider
impl RefUnwindSafe for ExecutionProvider
impl Send for ExecutionProvider
impl Sync for ExecutionProvider
impl Unpin for ExecutionProvider
impl UnsafeUnpin for ExecutionProvider
impl UnwindSafe for ExecutionProvider
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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