libffcv / ffcv

FFCV: Fast Forward Computer Vision (and other ML workloads!)
https://ffcv.io
Apache License 2.0
2.82k stars 178 forks source link

Loader.__len__ is not a pure function #163

Closed dpaleka closed 2 years ago

dpaleka commented 2 years ago

Counterintuitively, calling len() on a ffcv.loader.Loader instance modifies its internal state: https://github.com/libffcv/ffcv/blob/bfd9b3d85e31360fada2ecf63bea5602e4774ba3/ffcv/loader/loader.py#L253-L258

This causes the bug in #140 when paired with OrderOption.QUASI_RANDOM. I suppose the culprit is this line: https://github.com/libffcv/ffcv/blob/bfd9b3d85e31360fada2ecf63bea5602e4774ba3/ffcv/traversal_order/quasi_random.py#L24

GuillaumeLeclerc commented 2 years ago

Thanks @dpaleka It should be an easy fix :)

GuillaumeLeclerc commented 2 years ago

Thanks for the report, it will be in the next release