pub enum ReduceOp {
Sum,
Mean,
Max,
Min,
Product,
}Expand description
Reduction operators supported by the ring all-reduce.
The associative combine used during the reduce-scatter phase is exposed via
ReduceOp::apply, and the neutral element of that combine via
ReduceOp::identity. ReduceOp::Mean reuses the additive combine and is
finalised by dividing the accumulated sum by the world size.
Variants§
Sum
Elementwise sum across all workers.
Mean
Elementwise arithmetic mean across all workers (sum divided by world size).
Max
Elementwise maximum across all workers.
Min
Elementwise minimum across all workers.
Product
Elementwise product across all workers.
Implementations§
Source§impl ReduceOp
impl ReduceOp
Sourcepub fn apply<A: Float>(self, a: A, b: A) -> A
pub fn apply<A: Float>(self, a: A, b: A) -> A
Combine two values with this operator.
Mean uses the same additive combine as Sum; the division by the world
size is applied once at the end of the reduction (see
ReduceOp::needs_mean_finalize).
Sourcepub fn identity<A: Float>(self) -> A
pub fn identity<A: Float>(self) -> A
Neutral element of the combine operator.
Folding identity with any value v via ReduceOp::apply yields v.
Sourcepub fn needs_mean_finalize(self) -> bool
pub fn needs_mean_finalize(self) -> bool
Whether the accumulated result must be divided by the world size.
This is true only for ReduceOp::Mean.
Trait Implementations§
impl Copy for ReduceOp
impl Eq for ReduceOp
impl StructuralPartialEq for ReduceOp
Auto Trait Implementations§
impl Freeze for ReduceOp
impl RefUnwindSafe for ReduceOp
impl Send for ReduceOp
impl Sync for ReduceOp
impl Unpin for ReduceOp
impl UnsafeUnpin for ReduceOp
impl UnwindSafe for ReduceOp
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar 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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.