Whether or not the current process is the local process, based on `xm.get_ordinal()` (for TPUs) first, then on `local_rank`.
(local_rank)
| 354 | |
| 355 | |
| 356 | def is_main_process(local_rank): |
| 357 | """ |
| 358 | Whether or not the current process is the local process, based on `xm.get_ordinal()` (for TPUs) first, then on |
| 359 | `local_rank`. |
| 360 | """ |
| 361 | if is_torch_xla_available(): |
| 362 | import torch_xla.core.xla_model as xm |
| 363 | |
| 364 | return xm.get_ordinal() == 0 |
| 365 | return local_rank in [-1, 0] |
| 366 | |
| 367 | |
| 368 | def total_processes_number(local_rank): |
no test coverage detected