Пример #1
0
 public _MultiWorkerIter(WorkerPool worker_pool, Func <NDArrayList, NDArrayList> batchify_fn,
                         BatchSampler batch_sampler,
                         bool pin_memory = false, int pin_device_id     = 0, WorkerFn worker_fn        = null,
                         int prefetch    = 0, Dataset <NDArray> dataset = null, DataLoader data_loader = null)
 {
     _worker_pool   = worker_pool;
     _batchify_fn   = batchify_fn;
     _batch_sampler = batch_sampler;
     _data_buffer   = new Dictionary <int, NDArrayList>();
     _rcvd_idx      = 0;
     _sent_idx      = 0;
     _iter          = _batch_sampler.GetEnumerator();
     _worker_fn     = worker_fn;
     _pin_memory    = pin_memory;
     _pin_device_id = pin_device_id;
     _dataset       = dataset;
     _data_loader   = data_loader;
     foreach (var item in Enumerable.Range(0, prefetch))
     {
         PushNext();
     }
 }