set_default_device

Function set_default_device 

Source
pub fn set_default_device(device: Device)
Expand description

Set the global default device

This affects the default device for new tensors created without an explicit device. It does not affect the current thread’s device context.

§Arguments

  • device - The device to set as the global default

§Thread Safety

This function is thread-safe and uses atomic operations to update the global default.

§Examples

use train_station::{Device, set_default_device, get_default_device};

// Set global default to CPU
set_default_device(Device::cpu());
assert_eq!(get_default_device(), Device::cpu());

// The global default affects new tensor creation
// (tensor creation would use this default device)