pub struct StreamDataLoaderBuilder<S, C = DefaultCollator, F = IdentityTransformFactory, I = NoWorkerInit, M = MemoryDisabled, N = PinDisabled, K = CheckpointDisabled> { /* private fields */ }Expand description
Builder for an explicitly sharded positive-worker stream loader.
Implementations§
Source§impl<S, C, F, I, M, N> StreamDataLoaderBuilder<S, C, F, I, M, N, CheckpointDisabled>
impl<S, C, F, I, M, N> StreamDataLoaderBuilder<S, C, F, I, M, N, CheckpointDisabled>
Sourcepub fn checkpointable(
self,
identity: impl Into<String>,
) -> StreamDataLoaderBuilder<S, C, F, I, M, N, CheckpointFresh>
pub fn checkpointable( self, identity: impl Into<String>, ) -> StreamDataLoaderBuilder<S, C, F, I, M, N, CheckpointFresh>
Enables exact checkpoints for an explicit replay-safe source identity.
Building requires a checkpoint factory, checkpointable sources/transforms, ordered delivery, no byte budget, no custom initializer, no persistence, and no timeout. Ordinary iterator batching has no checkpoint method.
use rusttorch_data::batches;
let mut iter = batches((0..4).map(Ok::<_, std::convert::Infallible>), 2, false).unwrap();
iter.checkpoint().unwrap();Sourcepub fn resume<SS, TS, CS>(
self,
identity: impl Into<String>,
state: StreamLoaderState<SS, TS, CS>,
) -> StreamDataLoaderBuilder<S, C, F, I, M, N, CheckpointResume<StreamLoaderState<SS, TS, CS>>>
pub fn resume<SS, TS, CS>( self, identity: impl Into<String>, state: StreamLoaderState<SS, TS, CS>, ) -> StreamDataLoaderBuilder<S, C, F, I, M, N, CheckpointResume<StreamLoaderState<SS, TS, CS>>>
Selects a serialized next-visible-batch stream checkpoint for resume.
Source§impl<S, C, F, N> StreamDataLoaderBuilder<S, C, F, NoWorkerInit, MemoryDisabled, N, CheckpointFresh>where
S: CheckpointSourceFactory,
S::Source: CheckpointableSource<Sample = S::Sample, Error = S::Error>,
<<S as WorkerSourceFactory>::Source as CheckpointableSource>::State: Send + 'static,
F: TransformFactory<S::Sample> + Send + Sync + 'static,
F::Transform: WorkerCheckpoint + Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as WorkerCheckpoint>::State: Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output: Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Error: Send + 'static,
F::Error: Send + 'static,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output> + Checkpointable,
N: StreamPinPolicy<S, C, F>,
impl<S, C, F, N> StreamDataLoaderBuilder<S, C, F, NoWorkerInit, MemoryDisabled, N, CheckpointFresh>where
S: CheckpointSourceFactory,
S::Source: CheckpointableSource<Sample = S::Sample, Error = S::Error>,
<<S as WorkerSourceFactory>::Source as CheckpointableSource>::State: Send + 'static,
F: TransformFactory<S::Sample> + Send + Sync + 'static,
F::Transform: WorkerCheckpoint + Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as WorkerCheckpoint>::State: Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output: Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Error: Send + 'static,
F::Error: Send + 'static,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output> + Checkpointable,
N: StreamPinPolicy<S, C, F>,
Sourcepub fn build(
self,
) -> Result<ExactStreamDataLoader<S, C, F, N>, StreamCheckpointBuildError<<S as WorkerSourceFactory>::Error, <F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Error>>
pub fn build( self, ) -> Result<ExactStreamDataLoader<S, C, F, N>, StreamCheckpointBuildError<<S as WorkerSourceFactory>::Error, <F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Error>>
Validates exact capabilities and constructs suspended worker instances.
Source§impl<S, C, F, N> StreamDataLoaderBuilder<S, C, F, NoWorkerInit, MemoryDisabled, N, CheckpointResume<StreamLoaderState<<<S as WorkerSourceFactory>::Source as CheckpointableSource>::State, <<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as WorkerCheckpoint>::State, <C as Checkpointable>::State>>>where
S: CheckpointSourceFactory,
S::Source: CheckpointableSource<Sample = S::Sample, Error = S::Error>,
<<S as WorkerSourceFactory>::Source as CheckpointableSource>::State: Send + 'static,
F: TransformFactory<S::Sample> + Send + Sync + 'static,
F::Transform: WorkerCheckpoint + Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as WorkerCheckpoint>::State: Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output: Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Error: Send + 'static,
F::Error: Send + 'static,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output> + Checkpointable,
N: StreamPinPolicy<S, C, F>,
impl<S, C, F, N> StreamDataLoaderBuilder<S, C, F, NoWorkerInit, MemoryDisabled, N, CheckpointResume<StreamLoaderState<<<S as WorkerSourceFactory>::Source as CheckpointableSource>::State, <<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as WorkerCheckpoint>::State, <C as Checkpointable>::State>>>where
S: CheckpointSourceFactory,
S::Source: CheckpointableSource<Sample = S::Sample, Error = S::Error>,
<<S as WorkerSourceFactory>::Source as CheckpointableSource>::State: Send + 'static,
F: TransformFactory<S::Sample> + Send + Sync + 'static,
F::Transform: WorkerCheckpoint + Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as WorkerCheckpoint>::State: Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output: Send + 'static,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Error: Send + 'static,
F::Error: Send + 'static,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output> + Checkpointable,
N: StreamPinPolicy<S, C, F>,
Sourcepub fn build(
self,
) -> Result<ExactStreamDataLoader<S, C, F, N>, StreamCheckpointBuildError<<S as WorkerSourceFactory>::Error, <F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Error>>
pub fn build( self, ) -> Result<ExactStreamDataLoader<S, C, F, N>, StreamCheckpointBuildError<<S as WorkerSourceFactory>::Error, <F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Error>>
Validates the envelope before callbacks, then all components before apply.
Source§impl<S> StreamDataLoaderBuilder<S>where
S: WorkerSourceFactory,
impl<S> StreamDataLoaderBuilder<S>where
S: WorkerSourceFactory,
Source§impl<S, C, F, I, M, N, K> StreamDataLoaderBuilder<S, C, F, I, M, N, K>
impl<S, C, F, I, M, N, K> StreamDataLoaderBuilder<S, C, F, I, M, N, K>
Sourcepub fn batch_size(self, batch_size: usize) -> Self
pub fn batch_size(self, batch_size: usize) -> Self
Sets the global coordinator batch size.
Sourcepub fn drop_last(self, drop_last: bool) -> Self
pub fn drop_last(self, drop_last: bool) -> Self
Selects whether the one final global short batch is omitted.
Sourcepub fn prefetch_factor(self, factor: usize) -> Self
pub fn prefetch_factor(self, factor: usize) -> Self
Sets bounded unpublished records permitted per worker.
In ordered mode, filling the complete global reassembly window with higher IDs before the next ID is observable is a stream protocol error.
Sourcepub fn prefetch_bytes(
self,
limit: NonZeroUsize,
) -> StreamDataLoaderBuilder<S, C, F, I, MemoryEnabled, N, K>
pub fn prefetch_bytes( self, limit: NonZeroUsize, ) -> StreamDataLoaderBuilder<S, C, F, I, MemoryEnabled, N, K>
Enables a nonzero byte budget for final post-transform records.
Ordered byte-bounded shards must emit strictly increasing sequence IDs. The coordinator tracks one bounded front waiter per shard and reports a protocol error when every active shard has advanced beyond a missing ID.
Sourcepub fn pin_memory(
self,
) -> StreamDataLoaderBuilder<S, C, F, I, M, PinEnabled<Auto>, K>
pub fn pin_memory( self, ) -> StreamDataLoaderBuilder<S, C, F, I, M, PinEnabled<Auto>, K>
Enables automatic recursive pinning for CUDA device zero when available.
Sourcepub fn pin_memory_for(
self,
device: Device,
) -> StreamDataLoaderBuilder<S, C, F, I, M, PinEnabled<Explicit>, K>
pub fn pin_memory_for( self, device: Device, ) -> StreamDataLoaderBuilder<S, C, F, I, M, PinEnabled<Explicit>, K>
Enables recursive pinning for one explicit, available CUDA device.
Sourcepub fn ordered(self, ordered: bool) -> Self
pub fn ordered(self, ordered: bool) -> Self
Selects globally sequenced or completion-order delivery.
Sourcepub fn in_order(self, in_order: bool) -> Self
pub fn in_order(self, in_order: bool) -> Self
Selects globally sequenced or completion-order delivery.
Sourcepub fn rank(self, rank: usize) -> Self
pub fn rank(self, rank: usize) -> Self
Sets the distributed rank included in worker and task contexts.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sets the cooperative timeout for each blocking iterator call.
Sourcepub fn persistent_workers(self, persistent: bool) -> Self
pub fn persistent_workers(self, persistent: bool) -> Self
Selects loader-owned persistent worker threads.
Sourcepub fn collate<C2>(
self,
collator: C2,
) -> StreamDataLoaderBuilder<S, C2, F, I, M, N, K>
pub fn collate<C2>( self, collator: C2, ) -> StreamDataLoaderBuilder<S, C2, F, I, M, N, K>
Replaces coordinator collation.
Sourcepub fn transform<T>(
self,
transform: T,
) -> StreamDataLoaderBuilder<S, C, CloneTransformFactory<T>, I, M, N, K>
pub fn transform<T>( self, transform: T, ) -> StreamDataLoaderBuilder<S, C, CloneTransformFactory<T>, I, M, N, K>
Clones one transform template for each worker lifecycle.
Sourcepub fn transform_factory<F2>(
self,
factory: F2,
) -> StreamDataLoaderBuilder<S, C, F2, I, M, N, K>
pub fn transform_factory<F2>( self, factory: F2, ) -> StreamDataLoaderBuilder<S, C, F2, I, M, N, K>
Replaces worker transform construction.
Sourcepub fn worker_init<I2>(
self,
worker_init: I2,
) -> StreamDataLoaderBuilder<S, C, F, I2, M, N, K>
pub fn worker_init<I2>( self, worker_init: I2, ) -> StreamDataLoaderBuilder<S, C, F, I2, M, N, K>
Replaces worker initialization.
Source§impl<S, C, F, I> StreamDataLoaderBuilder<S, C, F, I, MemoryDisabled, PinDisabled>
impl<S, C, F, I> StreamDataLoaderBuilder<S, C, F, I, MemoryDisabled, PinDisabled>
Sourcepub fn build(
self,
) -> Result<StreamDataLoader<S, C, F, I, MemoryDisabled, PinDisabled>>where
S: WorkerSourceFactory,
F: TransformFactory<S::Sample>,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output>,
I: WorkerInit,
pub fn build(
self,
) -> Result<StreamDataLoader<S, C, F, I, MemoryDisabled, PinDisabled>>where
S: WorkerSourceFactory,
F: TransformFactory<S::Sample>,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output>,
I: WorkerInit,
Validates configuration and builds an item-bounded, unpinned stream.
Source§impl<S, C, F, I> StreamDataLoaderBuilder<S, C, F, I, MemoryEnabled, PinDisabled>
impl<S, C, F, I> StreamDataLoaderBuilder<S, C, F, I, MemoryEnabled, PinDisabled>
Sourcepub fn build(
self,
) -> Result<StreamDataLoader<S, C, F, I, MemoryEnabled, PinDisabled>>where
S: WorkerSourceFactory,
F: TransformFactory<S::Sample>,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output: MemoryFootprint,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output>,
I: WorkerInit,
pub fn build(
self,
) -> Result<StreamDataLoader<S, C, F, I, MemoryEnabled, PinDisabled>>where
S: WorkerSourceFactory,
F: TransformFactory<S::Sample>,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output: MemoryFootprint,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output>,
I: WorkerInit,
Validates configuration and builds a byte-bounded, unpinned stream.
Source§impl<S, C, F, I, Q> StreamDataLoaderBuilder<S, C, F, I, MemoryDisabled, PinEnabled<Q>>
impl<S, C, F, I, Q> StreamDataLoaderBuilder<S, C, F, I, MemoryDisabled, PinEnabled<Q>>
Sourcepub fn build(
self,
) -> Result<StreamDataLoader<S, C, F, I, MemoryDisabled, PinEnabled<Q>>>where
S: WorkerSourceFactory,
F: TransformFactory<S::Sample>,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output>,
C::Batch: PinMemory,
I: WorkerInit,
pub fn build(
self,
) -> Result<StreamDataLoader<S, C, F, I, MemoryDisabled, PinEnabled<Q>>>where
S: WorkerSourceFactory,
F: TransformFactory<S::Sample>,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output>,
C::Batch: PinMemory,
I: WorkerInit,
Validates configuration and builds an item-bounded pinned stream.
Source§impl<S, C, F, I, Q> StreamDataLoaderBuilder<S, C, F, I, MemoryEnabled, PinEnabled<Q>>
impl<S, C, F, I, Q> StreamDataLoaderBuilder<S, C, F, I, MemoryEnabled, PinEnabled<Q>>
Sourcepub fn build(
self,
) -> Result<StreamDataLoader<S, C, F, I, MemoryEnabled, PinEnabled<Q>>>where
S: WorkerSourceFactory,
F: TransformFactory<S::Sample>,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output: MemoryFootprint,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output>,
C::Batch: PinMemory,
I: WorkerInit,
pub fn build(
self,
) -> Result<StreamDataLoader<S, C, F, I, MemoryEnabled, PinEnabled<Q>>>where
S: WorkerSourceFactory,
F: TransformFactory<S::Sample>,
<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output: MemoryFootprint,
C: Collate<<<F as TransformFactory<<S as WorkerSourceFactory>::Sample>>::Transform as Transform<<S as WorkerSourceFactory>::Sample>>::Output>,
C::Batch: PinMemory,
I: WorkerInit,
Validates configuration and builds a byte-bounded pinned stream.