MCPcopy Create free account
hub / github.com/modelscope/modelscope / _split_tensor

Function _split_tensor

modelscope/utils/megatron_utils.py:201–208  ·  view source on GitHub ↗
(tensor: torch.Tensor, num_partitions: int,
                  partition_dim: int)

Source from the content-addressed store, hash-verified

199
200
201def _split_tensor(tensor: torch.Tensor, num_partitions: int,
202 partition_dim: int) -> List[torch.Tensor]:
203 from megatron_util import mpu
204 per_partition_size = mpu.utils.divide(
205 tensor.size(partition_dim), num_partitions)
206 partitions_list = torch.split(
207 tensor, per_partition_size, dim=partition_dim)
208 return partitions_list

Callers 1

_split_checkpointFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…