Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
DeviceType.ixx File Reference

Device type definitions and conversion utilities for compute devices. More...

#include <stdexcept>
#include <algorithm>
#include <string>
#include <cctype>
#include <string_view>
#include <format>

Namespaces

namespace  Mila
 Mila main API namespace.

Enumerations

enum class  Mila::Dnn::Compute::DeviceType { Cpu , Cuda , Metal , Rocm }
 Enumeration of supported compute device types. More...

Functions

std::string Mila::Dnn::Compute::deviceTypeToString (DeviceType device_type)
 Converts a DeviceType to its string representation.
DeviceType Mila::Dnn::Compute::toDeviceType (std::string_view device_type)
 Converts a string to the corresponding DeviceType.

Detailed Description

Device type definitions and conversion utilities for compute devices.

Enumeration Type Documentation

◆ DeviceType

enum class Mila::Dnn::Compute::DeviceType
exportstrong

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.

Function Documentation

◆ deviceTypeToString()

std::string Mila::Dnn::Compute::deviceTypeToString ( DeviceType device_type)
export

Converts a DeviceType to its string representation.

Parameters
device_typeThe device type to convert.
Returns
std::string The string representation of the device type (Device::Cpu() or "CUDA").
Exceptions
std::invalid_argumentIf the device type is invalid.
Examples
/home/runner/work/Mila/Mila/Mila/Src/Dnn/Compute/ExecutionContext.ixx.

◆ 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_typeThe string representation of the device type.
Returns
DeviceType The corresponding device type enum value.
Exceptions
std::invalid_argumentIf the string does not represent a valid device type. Valid options are: Device::Cpu(), "CUDA", "AUTO".