Skip to main content

luma_tensor/device/
mod.rs

1pub mod cpu;
2#[cfg(feature = "cuda")]
3pub mod cuda;
4
5pub mod bool_ops;
6pub mod float_ops;
7pub mod int_ops;
8
9pub use bool_ops::BoolOps;
10pub use cpu::Cpu;
11pub use float_ops::FloatOps;
12pub use int_ops::IntOps;
13
14use crate::{Bool, Float, Int, dtype::Storage};
15
16pub trait Device: 'static + Clone + Send + Sync + Default + FloatOps<Self> + IntOps<Self> + BoolOps<Self> {
17    type FloatStorage: Storage<Self, Float>;
18    type IntStorage: Storage<Self, Int>;
19    type BoolStorage: Storage<Self, Bool>;
20
21    fn name(&self) -> String;
22
23    /// Whether two handles refer to the same underlying device.
24    ///
25    /// Defaults to `true` — correct for stateless devices like [`Cpu`].
26    /// Devices with distinct instances (e.g. [`Cuda`](crate::Cuda) with
27    /// multiple ordinals) must override this.
28    fn same_device(&self, _other: &Self) -> bool {
29        true
30    }
31}