use hmll_sys::{hmll_device, HMLL_DEVICE_CPU, HMLL_DEVICE_CUDA};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Device {
Cpu,
Cuda,
}
impl Device {
#[inline(always)]
pub(crate) const fn to_raw(self) -> hmll_device {
match self {
Device::Cpu => HMLL_DEVICE_CPU,
Device::Cuda => HMLL_DEVICE_CUDA,
}
}
#[allow(dead_code)]
#[inline(always)]
pub(crate) const fn from_raw(device: hmll_device) -> Self {
match device {
HMLL_DEVICE_CPU => Device::Cpu,
HMLL_DEVICE_CUDA => Device::Cuda,
}
}
}
impl Default for Device {
#[inline(always)]
fn default() -> Self {
Device::Cpu
}
}
impl std::fmt::Display for Device {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Device::Cpu => write!(f, "CPU"),
Device::Cuda => write!(f, "CUDA"),
}
}
}