(self, ranges, threads)
| 1507 | return "TORCH_CHECK" |
| 1508 | |
| 1509 | def decide_parallel_depth(self, ranges, threads): |
| 1510 | seq = self.size_hint() |
| 1511 | par = 1 |
| 1512 | depth = 0 |
| 1513 | for expr in ranges: |
| 1514 | hint = V.graph.sizevars.size_hint(expr, fallback=8192) |
| 1515 | if par >= 2 * threads or par == threads: |
| 1516 | break |
| 1517 | if seq // threads < config.cpp.min_chunk_size: |
| 1518 | # not enough work |
| 1519 | break |
| 1520 | depth += 1 |
| 1521 | par *= hint |
| 1522 | seq /= hint |
| 1523 | # if we assume thread number is dynamic, make sure we |
| 1524 | # have at least one parallel scope and let OMP runtime |
| 1525 | # to manage the serial vs. parallel. |
| 1526 | if config.cpp.dynamic_threads and depth == 0 and len(ranges) > 0: |
| 1527 | depth = 1 |
| 1528 | return depth |
| 1529 | |
| 1530 | @contextlib.contextmanager |
| 1531 | def write_to_suffix(self): |
no test coverage detected