#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Device {
Cpu,
Metal,
Mlx,
Ane,
Cuda,
Rocm,
Tpu,
Gpu,
Vulkan,
OpenGl,
DirectX,
WebGpu,
}
impl Device {
pub fn name(self) -> &'static str {
match self {
Device::Cpu => "CPU",
Device::Metal => "Metal",
Device::Mlx => "MLX",
Device::Ane => "ANE",
Device::Cuda => "CUDA",
Device::Rocm => "ROCm",
Device::Tpu => "TPU",
Device::Gpu => "GPU (wgpu)",
Device::Vulkan => "Vulkan",
Device::OpenGl => "OpenGL",
Device::DirectX => "DirectX 12",
Device::WebGpu => "WebGPU",
}
}
pub fn all() -> &'static [Device] {
&[
Device::Cpu,
Device::Metal,
Device::Mlx,
Device::Ane,
Device::Cuda,
Device::Rocm,
Device::Tpu,
Device::Gpu,
Device::Vulkan,
Device::OpenGl,
Device::DirectX,
Device::WebGpu,
]
}
}
impl std::fmt::Display for Device {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name())
}
}