pub fn current_device() -> DeviceExpand description
Get the current thread’s device context
§Returns
The current device context for this thread
§Thread Safety
This function is thread-safe and returns the device context for the current thread only.
§Examples
use train_station::{Device, current_device, with_device};
let initial_device = current_device();
assert!(initial_device.is_cpu());
with_device(Device::cpu(), || {
assert_eq!(current_device(), Device::cpu());
});
assert_eq!(current_device(), initial_device);