pub enum DeviceSpec {
Cpu,
Cuda {
device_id: usize,
},
Metal {
device_id: usize,
},
WebGpu,
Disk {
path: PathBuf,
},
}Expand description
Device specification parsed from a device string.
This enum represents different compute devices that can execute kernels. It’s used throughout the compilation pipeline for device selection and kernel caching.
Variants§
Cpu
CPU device (single-threaded or multi-threaded execution)
Cuda
CUDA GPU device with specific device ID
Metal
Metal GPU device (Apple Silicon) with specific device ID
WebGpu
WebGPU device (browser or native WebGPU)
Disk
File-backed device (memory-mapped, read-only). Matches Tinygrad’s DISK device. Cannot execute kernels — data is transferred to compute devices via COPY.
Implementations§
Source§impl DeviceSpec
impl DeviceSpec
Sourcepub fn canonicalize(&self) -> String
pub fn canonicalize(&self) -> String
Canonicalize the device spec to a standard string representation.
§Examples
use svod_dtype::DeviceSpec;
assert_eq!(DeviceSpec::Cpu.canonicalize(), "CPU");
assert_eq!(DeviceSpec::Cuda { device_id: 0 }.canonicalize(), "CUDA:0");
assert_eq!(DeviceSpec::Cuda { device_id: 1 }.canonicalize(), "CUDA:1");Sourcepub fn max_buffers(&self) -> Option<usize>
pub fn max_buffers(&self) -> Option<usize>
Get maximum buffer count for this device.
Returns None if the device has no buffer limit (effectively unlimited).
Known limits:
- Metal: 31 buffers (Apple Silicon hardware limit)
- WebGPU: 8 buffers (WebGPU specification limit)
- CPU/CUDA: None (no practical limit)
- Disk: None (file-backed, no kernel execution)
Sourcepub fn base_type(&self) -> &'static str
pub fn base_type(&self) -> &'static str
Get the base device type string (strips device ID / path).
Used for device factory lookup and cache key construction.
Unlike canonicalize(), this returns a static string without device ID.
§Examples
use svod_dtype::DeviceSpec;
assert_eq!(DeviceSpec::Cpu.base_type(), "CPU");
assert_eq!(DeviceSpec::Cuda { device_id: 0 }.base_type(), "CUDA");
assert_eq!(DeviceSpec::Cuda { device_id: 1 }.base_type(), "CUDA");Trait Implementations§
Source§impl Clone for DeviceSpec
impl Clone for DeviceSpec
Source§fn clone(&self) -> DeviceSpec
fn clone(&self) -> DeviceSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DeviceSpec
impl Debug for DeviceSpec
Source§impl<'de> Deserialize<'de> for DeviceSpec
impl<'de> Deserialize<'de> for DeviceSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for DeviceSpec
impl Hash for DeviceSpec
Source§impl PartialEq for DeviceSpec
impl PartialEq for DeviceSpec
Source§fn eq(&self, other: &DeviceSpec) -> bool
fn eq(&self, other: &DeviceSpec) -> bool
self and other values to be equal, and is used by ==.