MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / _split

Function _split

sat/sgm/modules/cp_enc_dec.py:78–101  ·  view source on GitHub ↗
(input_, dim)

Source from the content-addressed store, hash-verified

76
77
78def _split(input_, dim):
79 cp_world_size = get_context_parallel_world_size()
80
81 if cp_world_size == 1:
82 return input_
83
84 cp_rank = get_context_parallel_rank()
85
86 # print('in _split, cp_rank:', cp_rank, 'input_size:', input_.shape)
87
88 inpu_first_frame_ = input_.transpose(0, dim)[:1].transpose(0, dim).contiguous()
89 input_ = input_.transpose(0, dim)[1:].transpose(0, dim).contiguous()
90 dim_size = input_.size()[dim] // cp_world_size
91
92 input_list = torch.split(input_, dim_size, dim=dim)
93 output = input_list[cp_rank]
94
95 if cp_rank == 0:
96 output = torch.cat([inpu_first_frame_, output], dim=dim)
97 output = output.contiguous()
98
99 # print('out _split, cp_rank:', cp_rank, 'output_size:', output.shape)
100
101 return output
102
103
104def _gather(input_, dim):

Callers

nothing calls this directly

Calls 2

Tested by

no test coverage detected