Helper function to synchronize (barrier) among all processes when using distributed training
()
| 136 | |
| 137 | |
| 138 | def synchronize(): |
| 139 | """ |
| 140 | Helper function to synchronize (barrier) among all processes when |
| 141 | using distributed training |
| 142 | """ |
| 143 | if not dist.is_available(): |
| 144 | return |
| 145 | if not dist.is_initialized(): |
| 146 | return |
| 147 | world_size = dist.get_world_size() |
| 148 | if world_size == 1: |
| 149 | return |
| 150 | dist.barrier() |
| 151 | |
| 152 | |
| 153 | @functools.lru_cache() |
nothing calls this directly
no outgoing calls
no test coverage detected