abracudabra.device.base#
Define the base device class.
Attributes#
The device type, e.g., |
|
The supported device types. |
Classes#
A device with a name and index. |
Module Contents#
- class abracudabra.device.base.Device[source]#
Bases:
NamedTuple
A device with a name and index.
- classmethod validate(device, idx=None)[source]#
Return a device, validating the device type and index.
- Parameters:
device (object) – The device type.
idx (object | None) – The optional device index.
- Returns:
The device.
- Return type:
- classmethod from_str(device, /)[source]#
Return a device from a string.
The string should be in the format
"device[:idx]"
.Examples
>>> Device.from_str("cpu") Device(type="cpu", idx=None) >>> Device.from_str("cuda:1") Device(type="cuda", idx=1)
- Parameters:
device (str)
- Return type: