Struct MultiThreadDataLoader
pub struct MultiThreadDataLoader<B, I, O>where
B: Backend,{ /* private fields */ }Expand description
A multi-threaded data loader that can be used to iterate over a dataset.
Implementations§
§impl<B, I, O> MultiThreadDataLoader<B, I, O>
impl<B, I, O> MultiThreadDataLoader<B, I, O>
pub fn new(
strategy: Box<dyn BatchStrategy<I>>,
dataset: Arc<dyn Dataset<I>>,
batcher: Arc<dyn Batcher<B, I, O>>,
num_threads: usize,
device: <B as Backend>::Device,
rng: Option<StdRng>,
) -> MultiThreadDataLoader<B, I, O>
pub fn new( strategy: Box<dyn BatchStrategy<I>>, dataset: Arc<dyn Dataset<I>>, batcher: Arc<dyn Batcher<B, I, O>>, num_threads: usize, device: <B as Backend>::Device, rng: Option<StdRng>, ) -> MultiThreadDataLoader<B, I, O>
Creates a new multi-threaded batch data loader.
§Arguments
strategy- The batch strategy.dataset- The dataset.batcher- The batcher.num_threads- The number of threads.device- The device to use when loading a batch.rng- The rng determining if the dataset is shuffled each time a dataloader iterator is created.
§Returns
The multi-threaded batch data loader.
Trait Implementations§
§impl<B, I, O> DataLoader<B, O> for MultiThreadDataLoader<B, I, O>
impl<B, I, O> DataLoader<B, O> for MultiThreadDataLoader<B, I, O>
§fn iter<'a>(&'a self) -> Box<dyn DataLoaderIterator<O, Item = O> + 'a>
fn iter<'a>(&'a self) -> Box<dyn DataLoaderIterator<O, Item = O> + 'a>
Returns a boxed iterator to iterate over the data loader.
§fn num_items(&self) -> usize
fn num_items(&self) -> usize
The number of items (not the number of batches nor the number of iterations),
corresponding to the items_total of the progress returned by the iterator.
Auto Trait Implementations§
impl<B, I, O> !Freeze for MultiThreadDataLoader<B, I, O>
impl<B, I, O> !RefUnwindSafe for MultiThreadDataLoader<B, I, O>
impl<B, I, O> Send for MultiThreadDataLoader<B, I, O>
impl<B, I, O> Sync for MultiThreadDataLoader<B, I, O>
impl<B, I, O> Unpin for MultiThreadDataLoader<B, I, O>
impl<B, I, O> !UnwindSafe for MultiThreadDataLoader<B, I, O>
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