(obj, weight: torch.Tensor, distributed: bool = False)
| 50 | |
| 51 | |
| 52 | def recursive_average(obj, weight: torch.Tensor, distributed: bool = False): |
| 53 | obj = recursive_sum(obj, weight, distributed) |
| 54 | weight = weight.sum() |
| 55 | if distributed: |
| 56 | torch.distributed.all_reduce(weight, op=ReduceOp.SUM) |
| 57 | # Normalize weight to be sum-to-1 |
| 58 | obj = recursive_divide(obj, weight) |
| 59 | return obj, weight |
no test coverage detected
searching dependent graphs…