Trait Device

pub trait Device:
    Default
    + Clone
    + Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn from_id(device_id: DeviceId) -> Self;
    fn to_id(&self) -> DeviceId;
    fn device_count(type_id: u16) -> usize;

    // Provided method
    fn device_count_total() -> usize { ... }
}
Expand description

Device trait for all cubecl devices.

Required Methods§

fn from_id(device_id: DeviceId) -> Self

Create a device from its id.

fn to_id(&self) -> DeviceId

Retrieve the device id from the device.

fn device_count(type_id: u16) -> usize

Returns the number of devices available under the provided type id.

Provided Methods§

fn device_count_total() -> usize

Returns the total number of devices that can be handled by the runtime.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl Device for AmdDevice

§

fn from_id(device_id: DeviceId) -> AmdDevice

§

fn to_id(&self) -> DeviceId

§

fn device_count(_type_id: u16) -> usize

§

impl Device for CudaDevice

§

fn from_id(device_id: DeviceId) -> CudaDevice

§

fn to_id(&self) -> DeviceId

§

fn device_count(_type_id: u16) -> usize

§

impl Device for NdArrayDevice

§

fn from_id(_device_id: DeviceId) -> NdArrayDevice

§

fn to_id(&self) -> DeviceId

§

fn device_count(_type_id: u16) -> usize

§

impl Device for WgpuDevice

§

fn from_id(device_id: DeviceId) -> WgpuDevice

§

fn to_id(&self) -> DeviceId

§

fn device_count(type_id: u16) -> usize

§

fn device_count_total() -> usize

Implementors§