burn_tensor/tensor/backend/
device.rs

1/// The device id.
2#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, new)]
3pub struct DeviceId {
4    /// The type id identifies the type of the device.
5    pub type_id: u16,
6    /// The index id identifies the device number.
7    pub index_id: u32,
8}
9
10/// The handle device trait allows to get an id for a backend device.
11pub trait DeviceOps: Clone + Default + PartialEq + Send + Sync + core::fmt::Debug {
12    /// Return the [device id](DeviceId).
13    fn id(&self) -> DeviceId;
14}
15
16impl core::fmt::Display for DeviceId {
17    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
18        f.write_fmt(format_args!("{:?}", self))
19    }
20}