|
| static constexpr DeviceId | Cpu () noexcept |
| | Create CPU device identifier.
|
| static constexpr DeviceId | Cuda (int index) noexcept |
| | Create CUDA device identifier.
|
|
template<DeviceType TDeviceType> |
| static constexpr DeviceId | getDeviceId (int index) noexcept |
| static constexpr DeviceId | Metal (int index) noexcept |
| | Create Metal device identifier.
|
| static constexpr DeviceId | Rocm (int index) noexcept |
| | Create ROCm device identifier.
|
Abstract interface for compute device implementations.
Defines the common interface for all compute device types (CPU, CUDA, Metal, ROCm, etc.). Concrete device implementations inherit from this class and are registered with DeviceRegistry for runtime discovery.
This class also serves as the primary factory for DeviceId values via static methods, providing a clean API: Device::Cuda(0), Device::Cpu().
Current free and total device memory.
Answers "will this model fit" together with a footprint from Model::getRequiredMemory. Zeroed by default for devices with no distinct memory pool to report; a caller seeing total_bytes == 0 should treat the figure as unavailable rather than as a device with no memory.
NOTE on Windows: WDDM oversubscribes into shared host memory rather than failing, so free_bytes running out does not produce an allocation error – it produces a model that runs pathologically slowly. Callers should warn rather than refuse.
Reimplemented in Mila::Dnn::Compute::CudaDevice.