Registry of discovered compute devices with lazy instantiation.
More...
|
|
static DeviceRegistry & | instance () |
Registry of discovered compute devices with lazy instantiation.
Thread-safe singleton that stores registered DeviceId values and creates concrete Device instances on-demand. Device registrars register lightweight DeviceId values during initialization; Device objects are created lazily when first requested and then cached for subsequent calls.
◆ getDevice()
| std::shared_ptr< Device > Mila::Dnn::Compute::DeviceRegistry::getDevice |
( |
DeviceId | id | ) |
const |
|
inline |
Retrieve or create a device by ID.
Validates that the DeviceId is registered, then returns a cached Device instance. If this is the first request, invokes the factory callback to create the device and caches it.
- Parameters
-
- Returns
- std::shared_ptr<Device> Cached device instance with properties
- Exceptions
-
| std::runtime_error | If DeviceId is not registered or creation fails |
◆ getDeviceCount()
| std::size_t Mila::Dnn::Compute::DeviceRegistry::getDeviceCount |
( |
DeviceType | device_type | ) |
const |
|
inlinenoexcept |
Return number of registered devices for the given DeviceType.
- Parameters
-
| device_type | Device type to count |
- Returns
- std::size_t Number of registered devices of this type (0 on error)
◆ hasDevice()
| bool Mila::Dnn::Compute::DeviceRegistry::hasDevice |
( |
DeviceId | id | ) |
const |
|
inlinenoexcept |
Non-throwing check whether a specific DeviceId has been registered.
- Parameters
-
- Returns
- bool True if device is registered, false otherwise (or on error)
◆ hasDeviceType()
| bool Mila::Dnn::Compute::DeviceRegistry::hasDeviceType |
( |
DeviceType | type | ) |
const |
|
inline |
Check whether a specific DeviceType has been registered.
- Parameters
-
| type | Device type to check (Cpu, Cuda, Metal, Rocm) |
- Returns
- bool True if at least one device of this type is registered
◆ listDeviceIds()
| std::vector< DeviceId > Mila::Dnn::Compute::DeviceRegistry::listDeviceIds |
( |
| ) |
const |
|
inline |
List registered DeviceId values.
- Returns
- std::vector<DeviceId> Vector of registered device identifiers
◆ listDeviceTypes()
| std::vector< DeviceType > Mila::Dnn::Compute::DeviceRegistry::listDeviceTypes |
( |
| ) |
const |
|
inline |
List registered device types (unique).
- Returns
- std::vector<DeviceType> Vector of unique device types
◆ registerDevice()
| void Mila::Dnn::Compute::DeviceRegistry::registerDevice |
( |
DeviceId | id, |
|
|
DeviceFactory | factory ) |
|
inline |
Register a discovered DeviceId with factory callback.
- Parameters
-
| id | Device identifier to register |
| factory | Factory function to create the device instance |
- Exceptions
-
| std::runtime_error | If DeviceId is already registered |
The documentation for this class was generated from the following file: