Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::Device Class Referenceabstractexport

Abstract interface for compute device implementations. More...

Inheritance diagram for Mila::Dnn::Compute::Device:

Public Member Functions

virtual ~Device ()=default
virtual DeviceId getDeviceId () const =0
 Gets the device identifier.
virtual std::string getDeviceName () const =0
 Gets the human-readable device name.
virtual constexpr DeviceType getDeviceType () const =0
 Gets the device type.

Static Public Member Functions

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.

Detailed Description

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().

Constructor & Destructor Documentation

◆ ~Device()

virtual Mila::Dnn::Compute::Device::~Device ( )
virtualdefault

Member Function Documentation

◆ Cpu()

constexpr DeviceId Mila::Dnn::Compute::Device::Cpu ( )
inlinestaticconstexprnoexcept

Create CPU device identifier.

Returns a DeviceId representing the CPU device. CPU is always index 0 (single logical CPU device).

Returns
DeviceId CPU device identifier.
Here is the caller graph for this function:

◆ Cuda()

constexpr DeviceId Mila::Dnn::Compute::Device::Cuda ( int index)
inlinestaticconstexprnoexcept

Create CUDA device identifier.

Parameters
indexZero-based CUDA device index (0, 1, 2, ...).
Returns
DeviceId CUDA device identifier.
Here is the caller graph for this function:

◆ getDeviceId() [1/2]

virtual DeviceId Mila::Dnn::Compute::Device::getDeviceId ( ) const
pure virtual

Gets the device identifier.

Returns
DeviceId The identifier for this device (type + index).

Implemented in Mila::Dnn::Compute::CpuDevice, and Mila::Dnn::Compute::CudaDevice.

◆ getDeviceId() [2/2]

template<DeviceType TDeviceType>
constexpr DeviceId Mila::Dnn::Compute::Device::getDeviceId ( int index)
inlinestaticconstexprnoexcept

◆ getDeviceName()

virtual std::string Mila::Dnn::Compute::Device::getDeviceName ( ) const
pure virtual

Gets the human-readable device name.

Returns
std::string Device name (e.g., "CPU:0", "CUDA:0", "Metal:1").

Implemented in Mila::Dnn::Compute::CpuDevice, and Mila::Dnn::Compute::CudaDevice.

◆ getDeviceType()

virtual constexpr DeviceType Mila::Dnn::Compute::Device::getDeviceType ( ) const
constexprpure virtual

Gets the device type.

Returns
DeviceType The type of this device (Cpu, Cuda, Metal, Rocm).

Implemented in Mila::Dnn::Compute::CpuDevice, and Mila::Dnn::Compute::CudaDevice.

◆ Metal()

constexpr DeviceId Mila::Dnn::Compute::Device::Metal ( int index)
inlinestaticconstexprnoexcept

Create Metal device identifier.

Parameters
indexZero-based Metal device index.
Returns
DeviceId Metal device identifier.

◆ Rocm()

constexpr DeviceId Mila::Dnn::Compute::Device::Rocm ( int index)
inlinestaticconstexprnoexcept

Create ROCm device identifier.

Parameters
indexZero-based ROCm device index.
Returns
DeviceId ROCm device identifier.

The documentation for this class was generated from the following file: