MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / get_mapping_to_flat_buffer

Function get_mapping_to_flat_buffer

deepspeed/runtime/zero/utils.py:211–221  ·  view source on GitHub ↗
(tensors: List[torch.Tensor])

Source from the content-addressed store, hash-verified

209
210
211def get_mapping_to_flat_buffer(tensors: List[torch.Tensor]) -> List[Tuple[torch.Tensor, int, int]]:
212 tensor_infos: List[Tuple[torch.Tensor, int, int]] = []
213
214 offset = 0
215 for tensor in tensors:
216 tensor_numel = tensor.numel()
217 # record some data so we can restore the device tensor later
218 tensor_infos.append((tensor, offset, tensor_numel))
219 offset += tensor_numel
220
221 return tensor_infos
222
223
224def defragment(tensors: List[torch.Tensor]) -> torch.Tensor:

Callers 3

offload_statesMethod · 0.90
reload_statesMethod · 0.90
defragmentFunction · 0.85

Calls 2

numelMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected