pub struct PartitionedReducer { /* private fields */ }Expand description
Performs memory-efficient reductions by splitting input into fixed-size chunks and accumulating partial results.
Implementations§
Source§impl PartitionedReducer
impl PartitionedReducer
Sourcepub fn new(config: PartitionConfig) -> Self
pub fn new(config: PartitionConfig) -> Self
Create a new reducer with the given configuration.
Sourcepub fn reduce_all(&mut self, data: &[f64]) -> Result<f64, PartitionedError>
pub fn reduce_all(&mut self, data: &[f64]) -> Result<f64, PartitionedError>
Reduce all elements of a flat 1-D slice to a single scalar.
Sourcepub fn reduce_axis(
&mut self,
data: &[f64],
shape: &[usize],
axis: usize,
) -> Result<(Vec<f64>, Vec<usize>), PartitionedError>
pub fn reduce_axis( &mut self, data: &[f64], shape: &[usize], axis: usize, ) -> Result<(Vec<f64>, Vec<usize>), PartitionedError>
Reduce along a single axis of an N-dimensional tensor.
data is the row-major flat representation of a tensor with the given
shape. The returned value is the flat representation of the reduced
tensor together with its shape (the axis dimension is removed).
Sourcepub fn log_sum_exp(&self, data: &[f64]) -> Result<f64, PartitionedError>
pub fn log_sum_exp(&self, data: &[f64]) -> Result<f64, PartitionedError>
Numerically stable log-sum-exp: log(Σ exp(x_i)).
Uses the max-subtraction trick to avoid overflow.
Sourcepub fn stats(&self) -> &PartitionedStats
pub fn stats(&self) -> &PartitionedStats
Return the accumulated statistics since the last reset.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset accumulated statistics.
Auto Trait Implementations§
impl Freeze for PartitionedReducer
impl RefUnwindSafe for PartitionedReducer
impl Send for PartitionedReducer
impl Sync for PartitionedReducer
impl Unpin for PartitionedReducer
impl UnsafeUnpin for PartitionedReducer
impl UnwindSafe for PartitionedReducer
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 more