oxmera-core 0.5.2

Core types for oxmera: dtype, shape, strides, layout, device handles, and the typed error taxonomy.
Documentation
//! Device handles.

/// Where a tensor's storage lives and where its work runs.
///
/// This is a *handle*, not a backend: it names a place. The backend
/// registry resolves a handle to an implementation; this crate must never
/// know how.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Device {
    /// The multi-threaded CPU backend — always available.
    Cpu,
    /// An Apple-Silicon GPU via Metal, by device index.
    Metal {
        /// Zero-based device index. Registration adds device 0 only; a
        /// higher index resolves to `BackendUnavailable`
        /// (see `docs/LIMITATIONS.md`).
        index: usize,
    },
    /// An NVIDIA GPU, by device index — served by `oxmera-cuda` once a
    /// driver and device are registered (`oxmera_runtime::init`).
    Cuda {
        /// Zero-based device index. Registration adds device 0 only; a
        /// higher index resolves to `BackendUnavailable`
        /// (see `docs/LIMITATIONS.md`).
        index: usize,
    },
}

impl Device {
    /// A short stable name for the device kind (`"cpu"`, `"metal"`,
    /// `"cuda"`), used in error messages and `oxmera doctor` output.
    pub fn kind_name(self) -> &'static str {
        match self {
            Device::Cpu => "cpu",
            Device::Metal { .. } => "metal",
            Device::Cuda { .. } => "cuda",
        }
    }
}