pub struct DeviceConfig { /* private fields */ }Expand description
Configuration for the built-in HeuristicSelector.
Use the builder methods to customise thresholds and forced-device overrides.
§Examples
use tensorlogic_scirs_backend::device_manager::DeviceConfig;
// Enable GPU when tensors have ≥ 4 M elements
let cfg = DeviceConfig::default()
.with_gpu_available(true)
.with_gpu_threshold(4_194_304);Implementations§
Source§impl DeviceConfig
impl DeviceConfig
Sourcepub fn with_gpu_threshold(self, n: usize) -> Self
pub fn with_gpu_threshold(self, n: usize) -> Self
Set the element count threshold above which GPU execution is considered.
Tensors with fewer than n elements will always run on CPU regardless
of GPU availability.
Sourcepub fn with_gpu_available(self, avail: bool) -> Self
pub fn with_gpu_available(self, avail: bool) -> Self
Declare whether a GPU is available on the current system.
Sourcepub fn force_cpu(self) -> Self
pub fn force_cpu(self) -> Self
Force all operations to run on CPU, overriding every other setting.
Sourcepub fn force_gpu(self, idx: u32) -> Self
pub fn force_gpu(self, idx: u32) -> Self
Force all operations to run on the GPU with the given device index, overriding every other setting.
Sourcepub fn with_gpu_index(self, idx: u32) -> Self
pub fn with_gpu_index(self, idx: u32) -> Self
Set the GPU device index used when GPU execution is selected.
Trait Implementations§
Source§impl Clone for DeviceConfig
impl Clone for DeviceConfig
Source§fn clone(&self) -> DeviceConfig
fn clone(&self) -> DeviceConfig
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 DeviceConfig
impl Debug for DeviceConfig
Auto Trait Implementations§
impl Freeze for DeviceConfig
impl RefUnwindSafe for DeviceConfig
impl Send for DeviceConfig
impl Sync for DeviceConfig
impl Unpin for DeviceConfig
impl UnsafeUnpin for DeviceConfig
impl UnwindSafe for DeviceConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more