Device type definitions and conversion utilities for compute devices.
More...
#include <stdexcept>
#include <algorithm>
#include <string>
#include <cctype>
#include <string_view>
#include <format>
Device type definitions and conversion utilities for compute devices.
◆ DeviceType
Enumeration of supported compute device types.
Defines the types of compute devices that can be used for tensor operations and neural network operations.
| Enumerator |
|---|
| Cpu | CPU device type.
|
| Cuda | CUDA GPU device type.
|
◆ deviceTypeToString()
| std::string Mila::Dnn::Compute::deviceTypeToString |
( |
DeviceType | device_type | ) |
|
|
export |
Converts a DeviceType to its string representation.
- Parameters
-
| device_type | The device type to convert. |
- Returns
- std::string The string representation of the device type (Device::Cpu() or "CUDA").
- Exceptions
-
| std::invalid_argument | If the device type is invalid. |
◆ toDeviceType()
| DeviceType Mila::Dnn::Compute::toDeviceType |
( |
std::string_view | device_type | ) |
|
|
export |
Converts a string to the corresponding DeviceType.
Performs case-insensitive matching to convert device type strings to the corresponding enum value.
- Parameters
-
| device_type | The string representation of the device type. |
- Returns
- DeviceType The corresponding device type enum value.
- Exceptions
-
| std::invalid_argument | If the string does not represent a valid device type. Valid options are: Device::Cpu(), "CUDA", "AUTO". |