pub struct ParallelGradientComputer { /* private fields */ }Expand description
Parallel gradient computer using SciRS2-Core
Implementations§
Source§impl ParallelGradientComputer
impl ParallelGradientComputer
Sourcepub fn with_config(config: ParallelConfig) -> Self
pub fn with_config(config: ParallelConfig) -> Self
Create with custom configuration
Sourcepub fn set_config(&mut self, config: ParallelConfig)
pub fn set_config(&mut self, config: ParallelConfig)
Set configuration
Sourcepub fn config(&self) -> &ParallelConfig
pub fn config(&self) -> &ParallelConfig
Get current configuration
Sourcepub fn stats(&self) -> &ParallelStats
pub fn stats(&self) -> &ParallelStats
Get statistics
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset statistics
Sourcepub fn should_parallelize(&self, tensor_size: usize) -> bool
pub fn should_parallelize(&self, tensor_size: usize) -> bool
Check if a tensor should be processed in parallel
Sourcepub fn compute_optimal_chunk_size(&self, tensor_size: usize) -> usize
pub fn compute_optimal_chunk_size(&self, tensor_size: usize) -> usize
Compute optimal chunk size for a given tensor
Sourcepub fn compute_gradients_parallel<T>(
&mut self,
data: &[T],
) -> AutogradResult<Vec<T>>
pub fn compute_gradients_parallel<T>( &mut self, data: &[T], ) -> AutogradResult<Vec<T>>
Compute gradients in parallel for multiple tensors
This uses SciRS2-Core’s parallel operations to distribute gradient computation across multiple CPU cores with optimal work distribution.
Sourcepub fn parallel_element_wise_op<T, F>(
&mut self,
data: &[T],
op: F,
) -> AutogradResult<Vec<T>>
pub fn parallel_element_wise_op<T, F>( &mut self, data: &[T], op: F, ) -> AutogradResult<Vec<T>>
Apply a parallel operation to gradient data
This demonstrates integration with scirs2-core’s parallel_ops for element-wise operations on gradient tensors.
Sourcepub fn compute_with_intelligent_chunking<T>(
&mut self,
data: &[T],
grad_fn: impl Fn(&T) -> T + Send + Sync,
) -> AutogradResult<Vec<T>>
pub fn compute_with_intelligent_chunking<T>( &mut self, data: &[T], grad_fn: impl Fn(&T) -> T + Send + Sync, ) -> AutogradResult<Vec<T>>
Compute gradients using SciRS2’s intelligent chunking
This integrates with SciRS2-Core’s automatic performance optimization through intelligent chunking strategies.
Sourcepub fn report_performance(&self) -> String
pub fn report_performance(&self) -> String
Report current performance statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParallelGradientComputer
impl RefUnwindSafe for ParallelGradientComputer
impl Send for ParallelGradientComputer
impl Sync for ParallelGradientComputer
impl Unpin for ParallelGradientComputer
impl UnsafeUnpin for ParallelGradientComputer
impl UnwindSafe for ParallelGradientComputer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 more