MCPcopy
hub / github.com/dmlc/dgl / __iter__

Method __iter__

python/dgl/dataloading/dataloader.py:1137–1156  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1135 )
1136
1137 def __iter__(self):
1138 if (
1139 self.device.type == "cpu"
1140 and hasattr(psutil.Process, "cpu_affinity")
1141 and not self.cpu_affinity_enabled
1142 ):
1143 link = "https://docs.dgl.ai/tutorials/cpu/cpu_best_practises.html"
1144 dgl_warning(
1145 f"Dataloader CPU affinity opt is not enabled, consider switching it on "
1146 f"(see enable_cpu_affinity() or CPU best practices for DGL [{link}])"
1147 )
1148
1149 if self.shuffle:
1150 self.dataset.shuffle()
1151 # When using multiprocessing PyTorch sometimes set the number of PyTorch threads to 1
1152 # when spawning new Python threads. This drastically slows down pinning features.
1153 num_threads = torch.get_num_threads() if self.num_workers > 0 else None
1154 return _PrefetchingIter(
1155 self, super().__iter__(), num_threads=num_threads
1156 )
1157
1158 @contextmanager
1159 def enable_cpu_affinity(

Callers

nothing calls this directly

Calls 3

dgl_warningFunction · 0.85
_PrefetchingIterClass · 0.85
shuffleMethod · 0.45

Tested by

no test coverage detected