Skip to main content

GpuOptimizer

Trait GpuOptimizer 

Source
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§

Source

fn is_gpu_available(&self) -> bool

Check if GPU acceleration is available

Source

fn move_to_gpu(&mut self) -> Result<(), GpuOptimError>

Move optimizer state to GPU

Source

fn move_to_cpu(&mut self) -> Result<(), GpuOptimError>

Move optimizer state back to CPU

Source

fn step_gpu( &mut self, params: &mut Array<A, D>, gradients: &Array<A, D>, ) -> Result<(), GpuOptimError>

Perform optimization step on GPU

Provided Methods§

Source

fn to_gpu(&mut self) -> Result<(), GpuOptimError>

👎Deprecated since 0.3.2:

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.

Source

fn to_cpu(&mut self) -> Result<(), GpuOptimError>

👎Deprecated since 0.3.2:

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".

Implementors§