(input_, dim)
| 102 | |
| 103 | |
| 104 | def _gather(input_, dim): |
| 105 | cp_world_size = get_context_parallel_world_size() |
| 106 | |
| 107 | # Bypass the function if context parallel is 1 |
| 108 | if cp_world_size == 1: |
| 109 | return input_ |
| 110 | |
| 111 | group = get_context_parallel_group() |
| 112 | cp_rank = get_context_parallel_rank() |
| 113 | |
| 114 | # print('in _gather, cp_rank:', cp_rank, 'input_size:', input_.shape) |
| 115 | |
| 116 | input_first_frame_ = input_.transpose(0, dim)[:1].transpose(0, dim).contiguous() |
| 117 | if cp_rank == 0: |
| 118 | input_ = input_.transpose(0, dim)[1:].transpose(0, dim).contiguous() |
| 119 | |
| 120 | tensor_list = [torch.empty_like(torch.cat([input_first_frame_, input_], dim=dim))] + [ |
| 121 | torch.empty_like(input_) for _ in range(cp_world_size - 1) |
| 122 | ] |
| 123 | |
| 124 | if cp_rank == 0: |
| 125 | input_ = torch.cat([input_first_frame_, input_], dim=dim) |
| 126 | |
| 127 | tensor_list[cp_rank] = input_ |
| 128 | torch.distributed.all_gather(tensor_list, input_, group=group) |
| 129 | |
| 130 | output = torch.cat(tensor_list, dim=dim).contiguous() |
| 131 | |
| 132 | # print('out _gather, cp_rank:', cp_rank, 'output_size:', output.shape) |
| 133 | |
| 134 | return output |
| 135 | |
| 136 | |
| 137 | def _conv_split(input_, dim, kernel_size): |
nothing calls this directly
no test coverage detected