pub struct GpuOptimizer<O, A>{ /* private fields */ }Expand description
GPU-accelerated optimizer wrapper
Wraps any CPU optimizer to provide GPU acceleration using SciRS2’s GPU abstractions. Automatically handles host-device data transfer and GPU memory management.
§Examples
use optirs_core::optimizers::SGD;
use optirs_core::gpu_optimizer::{GpuOptimizer, GpuConfig};
use scirs2_core::ndarray::Array1;
let optimizer = SGD::new(0.01);
let config = GpuConfig::default();
// Create GPU-accelerated optimizer
let mut gpu_opt = GpuOptimizer::new(optimizer, config)?;
// Use like a normal optimizer - GPU acceleration is automatic
let params = Array1::from_vec(vec![1.0, 2.0, 3.0]);
let grads = Array1::from_vec(vec![0.1, 0.2, 0.3]);
let updated = gpu_opt.step(¶ms, &grads)?;Implementations§
Source§impl<O, A> GpuOptimizer<O, A>
impl<O, A> GpuOptimizer<O, A>
Sourcepub fn with_default_config(base_optimizer: O) -> Result<Self>
pub fn with_default_config(base_optimizer: O) -> Result<Self>
Creates a new GPU optimizer with default configuration
Sourcepub fn to_gpu(&self, _data: &ArrayView1<'_, A>) -> Result<()>
pub fn to_gpu(&self, _data: &ArrayView1<'_, A>) -> Result<()>
Transfer array to GPU
Note: Full implementation would use scirs2_core::gpu::GpuBuffer
Sourcepub fn from_gpu(&self) -> Result<Array1<A>>
pub fn from_gpu(&self) -> Result<Array1<A>>
Transfer array from GPU
Note: Full implementation would use scirs2_core::gpu::GpuBuffer
Sourcepub fn is_gpu_available(&self) -> bool
pub fn is_gpu_available(&self) -> bool
Check if GPU is available and initialized
Sourcepub fn gpu_backend(&self) -> Option<&str>
pub fn gpu_backend(&self) -> Option<&str>
Get GPU backend name
Sourcepub fn set_use_tensor_cores(&mut self, enable: bool)
pub fn set_use_tensor_cores(&mut self, enable: bool)
Enable/disable tensor core acceleration
Sourcepub fn set_use_mixed_precision(&mut self, enable: bool)
pub fn set_use_mixed_precision(&mut self, enable: bool)
Enable/disable mixed-precision training
Auto Trait Implementations§
impl<O, A> Freeze for GpuOptimizer<O, A>where
O: Freeze,
impl<O, A> RefUnwindSafe for GpuOptimizer<O, A>where
O: RefUnwindSafe,
A: RefUnwindSafe,
impl<O, A> Send for GpuOptimizer<O, A>
impl<O, A> Sync for GpuOptimizer<O, A>
impl<O, A> Unpin for GpuOptimizer<O, A>
impl<O, A> UnwindSafe for GpuOptimizer<O, A>where
O: UnwindSafe,
A: UnwindSafe,
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.