pub trait GpuOptimizer<A: Float, D: Dimension> {
// Required methods
fn is_gpu_available(&self) -> bool;
fn move_to_gpu(&mut self) -> Result<(), GpuOptimError>;
fn move_to_cpu(&mut self) -> Result<(), GpuOptimError>;
fn step_gpu(
&mut self,
params: &mut Array<A, D>,
gradients: &Array<A, D>,
) -> Result<(), GpuOptimError>;
// Provided methods
fn to_gpu(&mut self) -> Result<(), GpuOptimError> { ... }
fn to_cpu(&mut self) -> Result<(), GpuOptimError> { ... }
}Expand description
Trait for GPU-accelerated optimizers
Required Methods§
Sourcefn is_gpu_available(&self) -> bool
fn is_gpu_available(&self) -> bool
Check if GPU acceleration is available
Sourcefn move_to_gpu(&mut self) -> Result<(), GpuOptimError>
fn move_to_gpu(&mut self) -> Result<(), GpuOptimError>
Move optimizer state to GPU
Sourcefn move_to_cpu(&mut self) -> Result<(), GpuOptimError>
fn move_to_cpu(&mut self) -> Result<(), GpuOptimError>
Move optimizer state back to CPU
Provided Methods§
Sourcefn to_gpu(&mut self) -> Result<(), GpuOptimError>
👎Deprecated since 0.3.2: renamed to move_to_gpu
fn to_gpu(&mut self) -> Result<(), GpuOptimError>
renamed to move_to_gpu
Deprecated alias for Self::move_to_gpu.
to_gpu on a &mut self method triggers
clippy::wrong_self_convention (to_* names are conventionally
reserved for cheap &self -> owned conversions); move_to_gpu
names what this actually does. This shim delegates to
Self::move_to_gpu and exists only so 0.3.1-era callers keep
compiling.
Sourcefn to_cpu(&mut self) -> Result<(), GpuOptimError>
👎Deprecated since 0.3.2: renamed to move_to_cpu
fn to_cpu(&mut self) -> Result<(), GpuOptimError>
renamed to move_to_cpu
Deprecated alias for Self::move_to_cpu.
See Self::to_gpu for why this was renamed. This shim delegates
to Self::move_to_cpu and exists only so 0.3.1-era callers keep
compiling.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".