(self)
| 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( |
nothing calls this directly
no test coverage detected