pub struct FallbackConfig {
pub enabled: bool,
pub trigger_on_device_lost: bool,
pub trigger_on_no_backend: bool,
pub timeout_ms: Option<u64>,
pub log_on_fallback: bool,
}Expand description
Configuration that controls when and how CPU fallback is activated.
By default fallback is enabled and will trigger on GpuError::DeviceLost
and on “no backend” adapter-not-found errors.
Fields§
§enabled: boolWhether automatic CPU fallback is enabled at all.
When false, GPU errors are always propagated and cpu_op is never
called.
trigger_on_device_lost: boolTrigger fallback when the GPU error is GpuError::DeviceLost.
trigger_on_no_backend: boolTrigger fallback when the GPU error indicates no adapter / no backend
is available (e.g. GpuError::NoAdapter or
GpuError::BackendNotAvailable).
timeout_ms: Option<u64>If Some(ms), GPU operations that exceed this wall-clock duration will
fall back to CPU. The timeout is implemented at the caller level via
execute_with_fallback_timed; the free function
execute_with_fallback ignores this field.
log_on_fallback: boolEmit a diagnostic message to stderr when falling back to CPU.
Implementations§
Source§impl FallbackConfig
impl FallbackConfig
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
Create a configuration with fallback disabled entirely.
GPU errors are always propagated; the CPU closure is never called.
Sourcepub fn with_logging(self) -> Self
pub fn with_logging(self) -> Self
Create a configuration with verbose logging enabled.
Sourcepub fn with_timeout(self, timeout_ms: u64) -> Self
pub fn with_timeout(self, timeout_ms: u64) -> Self
Set an optional timeout in milliseconds.
Sourcepub fn should_fallback(&self, err: &GpuError) -> bool
pub fn should_fallback(&self, err: &GpuError) -> bool
Decide whether err should trigger a fallback to CPU.
Returns false whenever self.enabled == false, regardless of the
error kind.
Trait Implementations§
Source§impl Clone for FallbackConfig
impl Clone for FallbackConfig
Source§fn clone(&self) -> FallbackConfig
fn clone(&self) -> FallbackConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more