pulsatrix
Loading...
Searching...
No Matches
pulsatrix::DataLoader Class Reference

Orchestrates sampling and collation into batches – pulsatrix's DataLoader (PyTorch DataLoader / torch::data::DataLoader analogue). More...

#include <data_loader.hpp>

Public Member Functions

 DataLoader (std::shared_ptr< Dataset > dataset, DeviceBackend *backend, DataLoaderOptions options={})
 Constructs a DataLoader over a random-access Dataset.
 
 DataLoader (std::shared_ptr< IterableDataset > dataset, DeviceBackend *backend, DataLoaderOptions options={})
 Constructs a DataLoader over a streaming IterableDataset.
 
void reset_epoch ()
 Resets to the start of a new epoch (re-seeds/reshuffles the sampler, or resets the stream).
 
std::optional< Batch > next_batch ()
 Fetches the next batch.
 
int64_t num_batches () const
 Number of batches per epoch.
 

Detailed Description

Orchestrates sampling and collation into batches – pulsatrix's DataLoader (PyTorch DataLoader / torch::data::DataLoader analogue).

Note
Phase 1 ships a fully synchronous implementation (num_workers=0 is the only exercised path): DataThreadPool/BoundedQueue exist (see those headers) but are not yet wired into this class's fetch/collate path – wiring num_workers > 0 through a real staged pipeline is a dedicated, separately-tested later mission (Decision Point 7 in campaign_exai_dl_library_data_pipeline).

Constructor & Destructor Documentation

◆ DataLoader() [1/2]

pulsatrix::DataLoader::DataLoader ( std::shared_ptr< Dataset >  dataset,
DeviceBackend *  backend,
DataLoaderOptions  options = {} 
)

Constructs a DataLoader over a random-access Dataset.

Exceptions
std::invalid_argumentif dataset is null or options.batch_size <= 0.

◆ DataLoader() [2/2]

pulsatrix::DataLoader::DataLoader ( std::shared_ptr< IterableDataset >  dataset,
DeviceBackend *  backend,
DataLoaderOptions  options = {} 
)

Constructs a DataLoader over a streaming IterableDataset.

Exceptions
std::invalid_argumentif dataset is null, options.batch_size <= 0, or options.num_workers > 1 – sharded multi-worker streaming is out of scope for this phase (a single worker can safely consume the whole stream).

Member Function Documentation

◆ next_batch()

std::optional< Batch > pulsatrix::DataLoader::next_batch ( )

Fetches the next batch.

Returns
The next Batch, or std::nullopt once the epoch is exhausted (or, with drop_last=true, once fewer than batch_size samples remain).

◆ num_batches()

int64_t pulsatrix::DataLoader::num_batches ( ) const

Number of batches per epoch.

Exceptions
std::logic_errorif this DataLoader was constructed from an IterableDataset (its length is unknown ahead of iteration).

◆ reset_epoch()

void pulsatrix::DataLoader::reset_epoch ( )

Resets to the start of a new epoch (re-seeds/reshuffles the sampler, or resets the stream).


The documentation for this class was generated from the following file: