|
Mila
Deep Neural Network Library
|
Lightweight identifier for a compute device. More...
Public Member Functions | |
| constexpr | DeviceId () noexcept |
| Construct a default DeviceId. | |
| constexpr | DeviceId (DeviceType type, int index=0) noexcept |
| Construct a DeviceId from components. | |
| constexpr auto | operator<=> (const DeviceId &) const noexcept=default |
| Three-way comparison for DeviceId. | |
| std::string | toString () const |
| Convert to human-readable string. | |
Static Public Member Functions | |
| static DeviceId | parse (std::string_view device_name) |
| Parse a textual device identifier. | |
Public Attributes | |
| int | index = -1 |
| Zero-based device index for the given type. | |
| DeviceType | type |
| The device type (e.g., Cuda, Cpu, Metal, Rocm). | |
Lightweight identifier for a compute device.
Pairs a DeviceType with a zero-based index. Used throughout the API as a value type for device identification, function parameters, and class members.
Construction:
Equality- and order-comparable. Suitable as key in associative containers.
|
inlineconstexprnoexcept |
Construct a default DeviceId.
Default constructs to Cuda device 0.
|
inlineconstexprnoexcept |
Construct a DeviceId from components.
| type | DeviceType enum value. |
| index | Zero-based device index (default 0). |
|
constexprdefaultnoexcept |
Three-way comparison for DeviceId.
Provides total ordering and equality. Comparison is performed by first comparing type, then index.
|
inlinestatic |
Parse a textual device identifier.
Accepted forms:
Examples: "cuda:0", "cpu", "metal:1", "rocm:2"
| device_name | Text to parse (case-insensitive for type). |
| std::invalid_argument | If format is invalid or type is unknown. |
|
inline |
Convert to human-readable string.
Produces "<type>:<index>" using deviceTypeToString() for the type component (e.g., "Cuda:0", "CPU:0", "Metal:1").
Useful for logging, diagnostics, and configuration serialization.