pyiqa.data.prefetch_dataloader ============================== .. py:module:: pyiqa.data.prefetch_dataloader Module Contents --------------- .. py:class:: PrefetchGenerator(generator, num_prefetch_queue) Bases: :py:obj:`threading.Thread` A general prefetch generator. Ref: https://stackoverflow.com/questions/7323664/python-generator-pre-fetch :param generator: Python generator. :param num_prefetch_queue: Number of prefetch queue. :type num_prefetch_queue: int .. py:method:: run() Method representing the thread's activity. You may override this method in a subclass. The standard run() method invokes the callable object passed to the object's constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively. .. py:class:: PrefetchDataLoader(num_prefetch_queue, **kwargs) Bases: :py:obj:`torch.utils.data.DataLoader` Prefetch version of dataloader. Ref: https://github.com/IgorSusmelj/pytorch-styleguide/issues/5# TODO: Need to test on single gpu and ddp (multi-gpu). There is a known issue in ddp. :param num_prefetch_queue: Number of prefetch queue. :type num_prefetch_queue: int :param kwargs: Other arguments for dataloader. :type kwargs: dict .. py:class:: CPUPrefetcher(loader) CPU prefetcher. :param loader: Dataloader. .. py:method:: next() .. py:method:: reset() .. py:class:: CUDAPrefetcher(loader, opt) CUDA prefetcher. Ref: https://github.com/NVIDIA/apex/issues/304# It may consumes more GPU memory. :param loader: Dataloader. :param opt: Options. :type opt: dict .. py:method:: preload() .. py:method:: next() .. py:method:: reset()