pub enum DeviceType {
Cpu,
Cuda,
WebGpu,
DirectMl,
CoreMl,
}Expand description
Execution backend for ML inference.
Variants§
Cpu
Pure-Rust CPU execution (always available).
Cuda
NVIDIA CUDA via oxionnx-cuda (feature cuda).
WebGpu
WebGPU / wgpu compute backend via oxionnx-gpu (feature webgpu).
DirectMl
Microsoft DirectML (feature directml, Windows-only at runtime).
CoreMl
Apple CoreML. Reserved variant; no coreml feature exists yet, so
this device is never reported as available and auto() never
selects it. It exists so API consumers can exhaustively match on
DeviceType without having to guess whether CoreML will be added
later.
Implementations§
Source§impl DeviceType
impl DeviceType
Sourcepub fn auto() -> Self
pub fn auto() -> Self
Return the preferred device available in this build, in the order CUDA → DirectML → WebGPU → CPU. Always succeeds because CPU is unconditionally available.
The result is memoised for the lifetime of the process.
Sourcepub fn is_available(self) -> bool
pub fn is_available(self) -> bool
Report whether this device is usable in the current build / runtime environment. A device may be compiled in (feature-gated) yet still unavailable at runtime — e.g. no GPU detected.
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Short canonical name matching the feature flag / CLI spelling.
Retained for backward compatibility with existing call sites;
DeviceType::display_name is preferred for human-facing output.
Sourcepub fn display_name(self) -> &'static str
pub fn display_name(self) -> &'static str
Human-facing label — identical to Self::name for now, but
conceptually distinct so downstream UIs can swap in a friendlier
string later without affecting programmatic lookups.
Sourcepub fn probe_caps(self) -> DeviceCapabilities
pub fn probe_caps(self) -> DeviceCapabilities
Run the full cascade probe and return the richer
DeviceCapabilities record for this device.
Sourcepub fn list_available() -> Vec<Self>
pub fn list_available() -> Vec<Self>
Return every DeviceType whose backend is currently usable.
The returned vector always contains DeviceType::Cpu and is
ordered by the probe cascade (CPU last).
Sourcepub const fn all_variants() -> [Self; 5]
pub const fn all_variants() -> [Self; 5]
Every variant in enum declaration order.
Used by DeviceCapabilities::probe_all and the test suite.
Trait Implementations§
Source§impl Clone for DeviceType
impl Clone for DeviceType
Source§fn clone(&self) -> DeviceType
fn clone(&self) -> DeviceType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DeviceType
Source§impl Debug for DeviceType
impl Debug for DeviceType
Source§impl Default for DeviceType
impl Default for DeviceType
Source§impl Display for DeviceType
impl Display for DeviceType
impl Eq for DeviceType
Source§impl Hash for DeviceType
impl Hash for DeviceType
Source§impl PartialEq for DeviceType
impl PartialEq for DeviceType
Source§fn eq(&self, other: &DeviceType) -> bool
fn eq(&self, other: &DeviceType) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DeviceType
Auto Trait Implementations§
impl Freeze for DeviceType
impl RefUnwindSafe for DeviceType
impl Send for DeviceType
impl Sync for DeviceType
impl Unpin for DeviceType
impl UnsafeUnpin for DeviceType
impl UnwindSafe for DeviceType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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