(self, name, numel, dtype, track_usage)
| 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): |
nothing calls this directly
no test coverage detected