pub struct ParStrided<T> { /* private fields */ }Expand description
A parallel strided iterator over tensor elements.
This struct provides mutable access to tensor elements with strided access patterns optimized for parallel processing.
Implementations§
Source§impl<T: CommonBounds> ParStrided<T>
impl<T: CommonBounds> ParStrided<T>
Sourcepub fn shape(&self) -> &Shape
pub fn shape(&self) -> &Shape
Retrieves the shape of the tensor.
§Returns
A reference to the Shape struct representing the tensor’s dimensions.
Sourcepub fn strides(&self) -> &Strides
pub fn strides(&self) -> &Strides
Retrieves the strides of the tensor.
§Returns
A reference to the Strides struct representing the tensor’s stride information.
Sourcepub fn new<U: TensorInfo<T>>(tensor: U) -> Self
pub fn new<U: TensorInfo<T>>(tensor: U) -> Self
Creates a new ParStrided instance from a given tensor.
This constructor initializes the ParStrided iterator by determining the appropriate number of threads
based on the tensor’s outer loop size and Rayon’s current number of threads. It then divides the
iteration workload into intervals for parallel execution.
§Arguments
tensor- The tensor implementing theTensorInfo<T>trait to iterate over mutably.
§Returns
A new instance of ParStrided initialized with the provided tensor.
Sourcepub fn par_strided_fold<ID, F>(
self,
identity: ID,
fold_op: F,
) -> ParStridedFold<Self, ID, F>
pub fn par_strided_fold<ID, F>( self, identity: ID, fold_op: F, ) -> ParStridedFold<Self, ID, F>
Performs a parallel fold (reduce) operation over the tensor elements.
This method applies a folding function fold_op to accumulate tensor elements into an initial
identity value identity. It leverages parallel iteration to perform the fold operation efficiently.
§Type Parameters
ID- The type of the accumulator.F- The folding function.
§Arguments
identity- The initial value for the accumulator.fold_op- A function that takes the current accumulator and an element, returning the updated accumulator.
§Returns
A ParStridedFold instance that represents the fold operation.
Sourcepub fn strided_map<'a, F, U>(
self,
f: F,
) -> ParStridedMap<'a, ParStrided<T>, T, F>
pub fn strided_map<'a, F, U>( self, f: F, ) -> ParStridedMap<'a, ParStrided<T>, T, F>
Transforms the zipped iterators by applying a provided function to their items.
This method allows for element-wise operations on the zipped iterators by applying func to each item.
§Type Parameters
'a- The lifetime associated with the iterators.F- The function to apply to each item.U- The output type after applying the function.
§Arguments
f- A function that takes an item from the zipped iterator and returns a transformed value.
§Returns
A ParStridedMap instance that applies the provided function during iteration.
Trait Implementations§
Source§impl<T: Clone> Clone for ParStrided<T>
impl<T: Clone> Clone for ParStrided<T>
Source§fn clone(&self) -> ParStrided<T>
fn clone(&self) -> ParStrided<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: CommonBounds> IterGetSet for ParStrided<T>
impl<T: CommonBounds> IterGetSet for ParStrided<T>
Source§fn set_end_index(&mut self, end_index: usize)
fn set_end_index(&mut self, end_index: usize)
Source§fn set_intervals(&mut self, intervals: Arc<Vec<(usize, usize)>>)
fn set_intervals(&mut self, intervals: Arc<Vec<(usize, usize)>>)
Source§fn set_strides(&mut self, strides: Strides)
fn set_strides(&mut self, strides: Strides)
Source§fn set_shape(&mut self, shape: Shape)
fn set_shape(&mut self, shape: Shape)
Source§fn broadcast_set_strides(&mut self, shape: &Shape)
fn broadcast_set_strides(&mut self, shape: &Shape)
Source§fn outer_loop_size(&self) -> usize
fn outer_loop_size(&self) -> usize
Source§fn inner_loop_size(&self) -> usize
fn inner_loop_size(&self) -> usize
Source§fn inner_loop_next(&mut self, index: usize) -> Self::Item
fn inner_loop_next(&mut self, index: usize) -> Self::Item
Source§impl<T: CommonBounds> ParStridedIteratorZip for ParStrided<T>
impl<T: CommonBounds> ParStridedIteratorZip for ParStrided<T>
Source§fn zip<'a, C>(self, other: C) -> ParStridedZip<'a, Self, C>where
C: UnindexedProducer + 'a + IterGetSet + ParallelIterator + ShapeManipulator,
<C as IterGetSet>::Item: Send,
Self: UnindexedProducer + ParallelIterator + ShapeManipulator,
<Self as IterGetSet>::Item: Send,
fn zip<'a, C>(self, other: C) -> ParStridedZip<'a, Self, C>where
C: UnindexedProducer + 'a + IterGetSet + ParallelIterator + ShapeManipulator,
<C as IterGetSet>::Item: Send,
Self: UnindexedProducer + ParallelIterator + ShapeManipulator,
<Self as IterGetSet>::Item: Send,
Source§impl<T> ParallelIterator for ParStrided<T>
impl<T> ParallelIterator for ParStrided<T>
Source§type Item = T
type Item = T
for_each method, this is the type of
item that your closure will be invoked with.Source§fn drive_unindexed<C>(self, consumer: C) -> C::Resultwhere
C: UnindexedConsumer<Self::Item>,
fn drive_unindexed<C>(self, consumer: C) -> C::Resultwhere
C: UnindexedConsumer<Self::Item>,
Source§fn for_each<OP>(self, op: OP)
fn for_each<OP>(self, op: OP)
OP on each item produced by the iterator, in parallel. Read moreSource§fn for_each_with<OP, T>(self, init: T, op: OP)
fn for_each_with<OP, T>(self, init: T, op: OP)
Source§fn for_each_init<OP, INIT, T>(self, init: INIT, op: OP)
fn for_each_init<OP, INIT, T>(self, init: INIT, op: OP)
OP on a value returned by init with each item produced by
the iterator, in parallel. Read moreSource§fn try_for_each<OP, R>(self, op: OP) -> R
fn try_for_each<OP, R>(self, op: OP) -> R
OP on each item produced by the iterator, in parallel. Read moreSource§fn try_for_each_with<OP, T, R>(self, init: T, op: OP) -> R
fn try_for_each_with<OP, T, R>(self, init: T, op: OP) -> R
OP on the given init value with each item
produced by the iterator, in parallel. Read moreSource§fn try_for_each_init<OP, INIT, T, R>(self, init: INIT, op: OP) -> R
fn try_for_each_init<OP, INIT, T, R>(self, init: INIT, op: OP) -> R
OP on a value returned by init with each item
produced by the iterator, in parallel. Read moreSource§fn map<F, R>(self, map_op: F) -> Map<Self, F>
fn map<F, R>(self, map_op: F) -> Map<Self, F>
map_op to each item of this iterator, producing a new
iterator with the results. Read moreSource§fn map_with<F, T, R>(self, init: T, map_op: F) -> MapWith<Self, T, F>
fn map_with<F, T, R>(self, init: T, map_op: F) -> MapWith<Self, T, F>
map_op to the given init value with each item of this
iterator, producing a new iterator with the results. Read moreSource§fn map_init<F, INIT, T, R>(
self,
init: INIT,
map_op: F,
) -> MapInit<Self, INIT, F>
fn map_init<F, INIT, T, R>( self, init: INIT, map_op: F, ) -> MapInit<Self, INIT, F>
map_op to a value returned by init with each item of this
iterator, producing a new iterator with the results. Read moreSource§fn inspect<OP>(self, inspect_op: OP) -> Inspect<Self, OP>
fn inspect<OP>(self, inspect_op: OP) -> Inspect<Self, OP>
inspect_op to a reference to each item of this iterator,
producing a new iterator passing through the original items. This is
often useful for debugging to see what’s happening in iterator stages. Read moreSource§fn update<F>(self, update_op: F) -> Update<Self, F>
fn update<F>(self, update_op: F) -> Update<Self, F>
Source§fn filter<P>(self, filter_op: P) -> Filter<Self, P>
fn filter<P>(self, filter_op: P) -> Filter<Self, P>
filter_op to each item of this iterator, producing a new
iterator with only the items that gave true results. Read moreSource§fn filter_map<P, R>(self, filter_op: P) -> FilterMap<Self, P>
fn filter_map<P, R>(self, filter_op: P) -> FilterMap<Self, P>
filter_op to each item of this iterator to get an Option,
producing a new iterator with only the items from Some results. Read moreSource§fn flat_map<F, PI>(self, map_op: F) -> FlatMap<Self, F>
fn flat_map<F, PI>(self, map_op: F) -> FlatMap<Self, F>
map_op to each item of this iterator to get nested parallel iterators,
producing a new parallel iterator that flattens these back into one. Read moreSource§fn flat_map_iter<F, SI>(self, map_op: F) -> FlatMapIter<Self, F>
fn flat_map_iter<F, SI>(self, map_op: F) -> FlatMapIter<Self, F>
map_op to each item of this iterator to get nested serial iterators,
producing a new parallel iterator that flattens these back into one. Read moreSource§fn flatten(self) -> Flatten<Self>where
Self::Item: IntoParallelIterator,
fn flatten(self) -> Flatten<Self>where
Self::Item: IntoParallelIterator,
Items into one large iterator. Read moreSource§fn flatten_iter(self) -> FlattenIter<Self>
fn flatten_iter(self) -> FlattenIter<Self>
Items into one large iterator. Read moreSource§fn reduce<OP, ID>(self, identity: ID, op: OP) -> Self::Item
fn reduce<OP, ID>(self, identity: ID, op: OP) -> Self::Item
op.
The argument identity should be a closure that can produce
“identity” value which may be inserted into the sequence as
needed to create opportunities for parallel execution. So, for
example, if you are doing a summation, then identity() ought
to produce something that represents the zero for your type
(but consider just calling sum() in that case). Read moreSource§fn reduce_with<OP>(self, op: OP) -> Option<Self::Item>
fn reduce_with<OP>(self, op: OP) -> Option<Self::Item>
op.
If the iterator is empty, None is returned; otherwise,
Some is returned. Read moreSource§fn try_reduce<T, OP, ID>(self, identity: ID, op: OP) -> Self::Item
fn try_reduce<T, OP, ID>(self, identity: ID, op: OP) -> Self::Item
Source§fn try_reduce_with<T, OP>(self, op: OP) -> Option<Self::Item>
fn try_reduce_with<T, OP>(self, op: OP) -> Option<Self::Item>
op. Read moreSource§fn fold<T, ID, F>(self, identity: ID, fold_op: F) -> Fold<Self, ID, F>
fn fold<T, ID, F>(self, identity: ID, fold_op: F) -> Fold<Self, ID, F>
22 3 77 89 46. If
you used sequential fold to add them (fold(0, |a,b| a+b),
you would wind up first adding 0 + 22, then 22 + 3, then 25 +
77, and so forth. The parallel fold works similarly except
that it first breaks up your list into sublists, and hence
instead of yielding up a single sum at the end, it yields up
multiple sums. The number of results is nondeterministic, as
is the point where the breaks occur. Read moreSource§fn fold_with<F, T>(self, init: T, fold_op: F) -> FoldWith<Self, T, F>
fn fold_with<F, T>(self, init: T, fold_op: F) -> FoldWith<Self, T, F>
fold_op to the given init value with each item of this
iterator, finally producing the value for further use. Read moreSource§fn try_fold<T, R, ID, F>(
self,
identity: ID,
fold_op: F,
) -> TryFold<Self, R, ID, F>
fn try_fold<T, R, ID, F>( self, identity: ID, fold_op: F, ) -> TryFold<Self, R, ID, F>
Source§fn try_fold_with<F, T, R>(self, init: T, fold_op: F) -> TryFoldWith<Self, R, F>
fn try_fold_with<F, T, R>(self, init: T, fold_op: F) -> TryFoldWith<Self, R, F>
init value. Read moreSource§fn min(self) -> Option<Self::Item>
fn min(self) -> Option<Self::Item>
None is returned; otherwise, Some(min)
is returned. Read moreSource§fn min_by<F>(self, f: F) -> Option<Self::Item>
fn min_by<F>(self, f: F) -> Option<Self::Item>
None is
returned; otherwise, Some(min) is returned. Read moreSource§fn min_by_key<K, F>(self, f: F) -> Option<Self::Item>
fn min_by_key<K, F>(self, f: F) -> Option<Self::Item>
None is returned;
otherwise, Some(item) is returned. Read moreSource§fn max(self) -> Option<Self::Item>
fn max(self) -> Option<Self::Item>
None is returned; otherwise, Some(max)
is returned. Read moreSource§fn max_by<F>(self, f: F) -> Option<Self::Item>
fn max_by<F>(self, f: F) -> Option<Self::Item>
None is
returned; otherwise, Some(max) is returned. Read moreSource§fn max_by_key<K, F>(self, f: F) -> Option<Self::Item>
fn max_by_key<K, F>(self, f: F) -> Option<Self::Item>
None is returned;
otherwise, Some(item) is returned. Read moreSource§fn chain<C>(self, chain: C) -> Chain<Self, <C as IntoParallelIterator>::Iter>where
C: IntoParallelIterator<Item = Self::Item>,
fn chain<C>(self, chain: C) -> Chain<Self, <C as IntoParallelIterator>::Iter>where
C: IntoParallelIterator<Item = Self::Item>,
Source§fn find_any<P>(self, predicate: P) -> Option<Self::Item>
fn find_any<P>(self, predicate: P) -> Option<Self::Item>
find on sequential iterators but
the item returned may not be the first one in the parallel
sequence which matches, since we search the entire sequence in parallel. Read moreSource§fn find_first<P>(self, predicate: P) -> Option<Self::Item>
fn find_first<P>(self, predicate: P) -> Option<Self::Item>
Source§fn find_last<P>(self, predicate: P) -> Option<Self::Item>
fn find_last<P>(self, predicate: P) -> Option<Self::Item>
Source§fn find_map_any<P, R>(self, predicate: P) -> Option<R>
fn find_map_any<P, R>(self, predicate: P) -> Option<R>
Source§fn find_map_first<P, R>(self, predicate: P) -> Option<R>
fn find_map_first<P, R>(self, predicate: P) -> Option<R>
Source§fn find_map_last<P, R>(self, predicate: P) -> Option<R>
fn find_map_last<P, R>(self, predicate: P) -> Option<R>
Source§fn any<P>(self, predicate: P) -> bool
fn any<P>(self, predicate: P) -> bool
Source§fn all<P>(self, predicate: P) -> bool
fn all<P>(self, predicate: P) -> bool
Source§fn while_some<T>(self) -> WhileSome<Self>
fn while_some<T>(self) -> WhileSome<Self>
Some items of this iterator, halting
as soon as any None is found. Read moreSource§fn panic_fuse(self) -> PanicFuse<Self>
fn panic_fuse(self) -> PanicFuse<Self>
Source§fn collect<C>(self) -> Cwhere
C: FromParallelIterator<Self::Item>,
fn collect<C>(self) -> Cwhere
C: FromParallelIterator<Self::Item>,
Source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where
Self: ParallelIterator<Item = (A, B)>,
FromA: Default + Send + ParallelExtend<A>,
FromB: Default + Send + ParallelExtend<B>,
A: Send,
B: Send,
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where
Self: ParallelIterator<Item = (A, B)>,
FromA: Default + Send + ParallelExtend<A>,
FromB: Default + Send + ParallelExtend<B>,
A: Send,
B: Send,
ParallelExtend containers. Read moreSource§fn partition<A, B, P>(self, predicate: P) -> (A, B)
fn partition<A, B, P>(self, predicate: P) -> (A, B)
ParallelExtend containers. Items for which the predicate returns
true go into the first container, and the rest go into the second. Read moreSource§fn partition_map<A, B, P, L, R>(self, predicate: P) -> (A, B)
fn partition_map<A, B, P, L, R>(self, predicate: P) -> (A, B)
ParallelExtend containers. Either::Left items go into
the first container, and Either::Right items go into the second. Read moreSource§fn intersperse(self, element: Self::Item) -> Intersperse<Self>
fn intersperse(self, element: Self::Item) -> Intersperse<Self>
Source§fn take_any(self, n: usize) -> TakeAny<Self>
fn take_any(self, n: usize) -> TakeAny<Self>
n elements from anywhere in the original iterator. Read moreSource§fn skip_any(self, n: usize) -> SkipAny<Self>
fn skip_any(self, n: usize) -> SkipAny<Self>
n elements from anywhere in the original iterator. Read moreSource§fn take_any_while<P>(self, predicate: P) -> TakeAnyWhile<Self, P>
fn take_any_while<P>(self, predicate: P) -> TakeAnyWhile<Self, P>
predicate returns false. Read moreSource§fn skip_any_while<P>(self, predicate: P) -> SkipAnyWhile<Self, P>
fn skip_any_while<P>(self, predicate: P) -> SkipAnyWhile<Self, P>
predicate returns false. Read moreSource§fn collect_vec_list(self) -> LinkedList<Vec<Self::Item>>
fn collect_vec_list(self) -> LinkedList<Vec<Self::Item>>
Source§impl<T: CommonBounds> ShapeManipulator for ParStrided<T>
impl<T: CommonBounds> ShapeManipulator for ParStrided<T>
Source§impl<T> UnindexedProducer for ParStrided<T>
impl<T> UnindexedProducer for ParStrided<T>
Auto Trait Implementations§
impl<T> Freeze for ParStrided<T>
impl<T> RefUnwindSafe for ParStrided<T>where
T: RefUnwindSafe,
impl<T> Send for ParStrided<T>
impl<T> Sync for ParStrided<T>
impl<T> Unpin for ParStrided<T>
impl<T> UnwindSafe for ParStrided<T>where
T: RefUnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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