Skip to main content

DeviceType

Enum DeviceType 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn probe_caps(self) -> DeviceCapabilities

Run the full cascade probe and return the richer DeviceCapabilities record for this device.

Source

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

Source

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

Source§

fn clone(&self) -> DeviceType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DeviceType

Source§

impl Debug for DeviceType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DeviceType

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for DeviceType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DeviceType

Source§

impl Hash for DeviceType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DeviceType

Source§

fn eq(&self, other: &DeviceType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DeviceType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.