MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / __init__

Method __init__

DeepSpeedExample/megatron/memory.py:49–71  ·  view source on GitHub ↗
(self, name, numel, dtype, track_usage)

Source from the content-addressed store, hash-verified

47
48 """
49 def __init__(self, name, numel, dtype, track_usage):
50 if torch.distributed.get_rank() == 0:
51 element_size = torch.tensor([], dtype=dtype).element_size()
52 print('> building the {} memory buffer with {} num elements '
53 'and {} dtype ({:.1f} MB)...'.format(
54 name, numel, dtype, numel*element_size/1024/1024),
55 flush=True)
56 self.name = name
57 self.numel = numel
58 self.dtype = dtype
59 self.data = torch.empty(self.numel,
60 dtype=self.dtype,
61 device=torch.cuda.current_device(),
62 requires_grad=False)
63
64 # Index tracking the start of the free memory.
65 self._start = 0
66
67 # Values used for tracking usage.
68 self.track_usage = track_usage
69 if self.track_usage:
70 self.in_use_value = 0.0
71 self.total_value = 0.0
72
73
74 def reset(self):

Callers

nothing calls this directly

Calls 2

get_rankMethod · 0.45
current_deviceMethod · 0.45

Tested by

no test coverage detected