pub struct GpuOptimizationContext { /* private fields */ }
Expand description
GPU-accelerated optimization context
Implementations§
Source§impl GpuOptimizationContext
impl GpuOptimizationContext
Sourcepub fn new(config: GpuOptimizationConfig) -> ScirsResult<Self>
pub fn new(config: GpuOptimizationConfig) -> ScirsResult<Self>
Create a new GPU optimization context
Sourcepub fn config(&self) -> &GpuOptimizationConfig
pub fn config(&self) -> &GpuOptimizationConfig
Get the configuration
Sourcepub fn context(&self) -> &Arc<GpuContext>
pub fn context(&self) -> &Arc<GpuContext>
Get the GPU context
Sourcepub fn allocate_workspace(&mut self, size: usize) -> ScirsResult<GpuWorkspace>
pub fn allocate_workspace(&mut self, size: usize) -> ScirsResult<GpuWorkspace>
Allocate GPU memory for optimization data
Sourcepub fn transfer_to_gpu<T>(
&self,
data: &Array2<T>,
) -> ScirsResult<OptimGpuArray<T>>
pub fn transfer_to_gpu<T>( &self, data: &Array2<T>, ) -> ScirsResult<OptimGpuArray<T>>
Transfer data from CPU to GPU using scirs2-core GPU abstractions
Sourcepub fn transfer_from_gpu<T>(
&self,
gpu_data: &OptimGpuArray<T>,
) -> ScirsResult<Array2<T>>
pub fn transfer_from_gpu<T>( &self, gpu_data: &OptimGpuArray<T>, ) -> ScirsResult<Array2<T>>
Transfer data from GPU to CPU using scirs2-core GPU abstractions
Sourcepub fn upload_array<T>(&self, data: &Array2<T>) -> ScirsResult<OptimGpuArray<T>>
pub fn upload_array<T>(&self, data: &Array2<T>) -> ScirsResult<OptimGpuArray<T>>
Upload array to GPU (alias for transfer_to_gpu)
Sourcepub fn download_array<T>(
&self,
gpu_data: &OptimGpuArray<T>,
) -> ScirsResult<Array2<T>>
pub fn download_array<T>( &self, gpu_data: &OptimGpuArray<T>, ) -> ScirsResult<Array2<T>>
Download array from GPU (alias for transfer_from_gpu)
Sourcepub fn evaluate_function_batch<F>(
&self,
function: &F,
points: &Array2<f64>,
) -> ScirsResult<Array1<f64>>where
F: GpuFunction,
pub fn evaluate_function_batch<F>(
&self,
function: &F,
points: &Array2<f64>,
) -> ScirsResult<Array1<f64>>where
F: GpuFunction,
Execute batch function evaluation
Sourcepub fn evaluate_gradient_batch<F>(
&self,
function: &F,
points: &Array2<f64>,
) -> ScirsResult<Array2<f64>>where
F: GpuFunction,
pub fn evaluate_gradient_batch<F>(
&self,
function: &F,
points: &Array2<f64>,
) -> ScirsResult<Array2<f64>>where
F: GpuFunction,
Execute batch gradient evaluation
Sourcepub fn compute_gradient_finite_diff<F>(
&self,
function: &F,
x: &Array1<f64>,
h: f64,
) -> ScirsResult<Array1<f64>>
pub fn compute_gradient_finite_diff<F>( &self, function: &F, x: &Array1<f64>, h: f64, ) -> ScirsResult<Array1<f64>>
Compute gradient using finite differences
Sourcepub fn compute_search_direction(
&self,
gradient: &Array1<f64>,
) -> ScirsResult<Array1<f64>>
pub fn compute_search_direction( &self, gradient: &Array1<f64>, ) -> ScirsResult<Array1<f64>>
Compute search direction (simple steepest descent for now)
Auto Trait Implementations§
impl Freeze for GpuOptimizationContext
impl !RefUnwindSafe for GpuOptimizationContext
impl Send for GpuOptimizationContext
impl Sync for GpuOptimizationContext
impl Unpin for GpuOptimizationContext
impl !UnwindSafe for GpuOptimizationContext
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.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.