pub enum DeviceType {
Cpu,
Cuda,
}Expand description
Device types supported by Train Station
This enum represents the different types of devices where tensor operations can be performed. Currently supports CPU and CUDA GPU devices.
§Variants
Cpu- CPU device for general-purpose computationCuda- CUDA GPU device for accelerated computation (feature-gated)
§Examples
use train_station::{DeviceType, Device};
let cpu_type = DeviceType::Cpu;
let cpu_device = Device::from(cpu_type);
assert!(cpu_device.is_cpu());
#[cfg(feature = "cuda")]
{
let cuda_type = DeviceType::Cuda;
let cuda_device = Device::from(cuda_type);
assert!(cuda_device.is_cuda());
}§Thread Safety
This type is thread-safe and can be shared between threads.
Variants§
Cpu
CPU device for general-purpose computation
Cuda
CUDA GPU device for accelerated computation (feature-gated)
Trait Implementations§
Source§impl Clone for DeviceType
impl Clone for DeviceType
Source§fn clone(&self) -> DeviceType
fn clone(&self) -> DeviceType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeviceType
impl Debug for DeviceType
Source§impl Display for DeviceType
impl Display for DeviceType
Source§impl From<DeviceType> for Device
impl From<DeviceType> for Device
Source§fn from(device_type: DeviceType) -> Self
fn from(device_type: DeviceType) -> Self
Convert DeviceType to Device with index 0
§Arguments
device_type- The device type to convert
§Returns
A Device with the specified type and index 0
§Panics
Panics if device_type is DeviceType::Cuda and CUDA is not available
or the feature is not enabled.
§Examples
use train_station::{Device, DeviceType};
let cpu_type = DeviceType::Cpu;
let cpu_device = Device::from(cpu_type);
assert!(cpu_device.is_cpu());
assert_eq!(cpu_device.index(), 0);Source§impl FromFieldValue for DeviceType
impl FromFieldValue for DeviceType
Source§fn from_field_value(
value: FieldValue,
field_name: &str,
) -> SerializationResult<Self>
fn from_field_value( value: FieldValue, field_name: &str, ) -> SerializationResult<Self>
Source§impl Hash for DeviceType
impl Hash for DeviceType
Source§impl PartialEq for DeviceType
impl PartialEq for DeviceType
Source§impl ToFieldValue for DeviceType
impl ToFieldValue for DeviceType
Source§fn to_field_value(&self) -> FieldValue
fn to_field_value(&self) -> FieldValue
Convert DeviceType to FieldValue for serialization
§Returns
Enum FieldValue with variant name (proper enum serialization)
impl Copy for DeviceType
impl Eq for DeviceType
impl StructuralPartialEq for DeviceType
Auto Trait Implementations§
impl Freeze for DeviceType
impl RefUnwindSafe for DeviceType
impl Send for DeviceType
impl Sync for DeviceType
impl Unpin for DeviceType
impl UnwindSafe for DeviceType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more