meta-pytorch / meta-pytorch/data
Additional basic functions beyond .map to allow for more functional programming
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 179
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 2
Description
🚀 The feature
For IterDataPipe, the .map maps a function over the items of an iterable. where the function has the form
f: Any -> Any
Other basic building blocks could be .pipe, .iter_map and .comsume. where
.pipewould takef: Iterable -> Iterable.iter_maptakesf: Any -> Iterable.comsumetakesf: Iterable -> Any
Motivation, pitch
Such an approach would allow for more flexible functional programming and would reduce most currently provided IterDataPipe classes to a simple functional call. For example
The Enumerator class would become
dp.pipe(enumerate)
This would immediately enable to use all itertools functions in this context.
The TarArchiveLoader could become
def iter_from_tar_archive(fd):
.<code to yield files from tar archive >
dp.iter_map(iter_from_tar_archive)
I believe using this approach, almost all provided classes could be written using less boilerplate using generator functions (essentially just writing the code inside __iter__ as a standalone generator function, possibly curried for convenience if other parameters are being used).
Would be great to hear if this was considered? Thanks!
Alternatives
The .pipe can already be written as
dp2 = IterableWrapper(enumerate(dp))
but I believe this would be a lot less nice than the above
dp.pipe(enumerate)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing IterDataPipe API and the IterableWrapper, Enumerator, and TarArchiveLoader examples named in the issue. Clarify the semantics and scope of pipe, iter_map, and consume, then establish the expected API and coverage before implementation; the issue currently presents a design proposal rather than a defined change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100