MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / _split

Function _split

codegeex/megatron/mpu/mappings.py:39–55  ·  view source on GitHub ↗

Split the tensor along its last dimension and keep the corresponding slice.

(input_)

Source from the content-addressed store, hash-verified

37
38
39def _split(input_):
40 """Split the tensor along its last dimension and keep the
41 corresponding slice."""
42
43 world_size = get_tensor_model_parallel_world_size()
44 # Bypass the function if we are using only 1 GPU.
45 if world_size == 1:
46 return input_
47
48 # Split along last dimension.
49 input_list = split_tensor_along_last_dim(input_, world_size)
50
51 # Note: torch.split does not create contiguous tensors by default.
52 rank = get_tensor_model_parallel_rank()
53 output = input_list[rank].contiguous()
54
55 return output
56
57
58def _gather(input_):

Callers 3

symbolicMethod · 0.85
forwardMethod · 0.85
backwardMethod · 0.85

Tested by

no test coverage detected