Expand description
Python bindings for torsh-data — Dataset and DataLoader APIs
Provides PyTorch-compatible dataset and data-loader primitives usable from Python. The bindings are deliberately concrete (no type-parameter leakage into Python) while still routing through the real torsh-data types wherever the API permits it.
§Design choices
-
PyDatasetstores samples asVec<Vec<f32>>(flat row-per-sample) so that it can implementtorsh_data::Datasetand be passed to the realtorsh_data::DataLoader::builder(). Each sample is exposed to Python as aVec<f32>. -
PyDataLoaderowns a concreteSimpleDataLoader<PyDataset>orSimpleRandomDataLoader<PyDataset>depending onshuffle. Because these are different types we erase them behind aPyDataLoaderStateenum so that a single#[pyclass]struct suffices. -
Iteration is implemented on the Rust side via
PyDataLoaderIter— a separate#[pyclass]that satisfies the__iter__/__next__protocol.
Structs§
- PyData
Loader - DataLoader wrapping a
PyDatasetwith configurable batching and shuffling. - PyData
Loader Iter - Python iterator that steps through pre-materialised batches.
- PyDataset
- In-memory dataset of f32 sample rows exposed to Python.
Functions§
- register_
data_ module - Register the
datasub-module into the parent module m.