Appends the current value of the recorded state variables to the recording.
(self)
| 98 | return return_logs |
| 99 | |
| 100 | def record(self) -> None: |
| 101 | # language=rst |
| 102 | """ |
| 103 | Appends the current value of the recorded state variables to the recording. |
| 104 | """ |
| 105 | self.clean = False |
| 106 | for v in self.state_vars: |
| 107 | data = getattr(self.obj, v).unsqueeze(0) |
| 108 | # self.recording[v].append(data.detach().clone().to(self.device)) |
| 109 | record = torch.empty_like( |
| 110 | data, device=self.device, requires_grad=False |
| 111 | ).copy_(data, non_blocking=True) |
| 112 | if self.sparse: |
| 113 | record = record.to_sparse() |
| 114 | self.recording[v].append(record) |
| 115 | # remove the oldest element (first in the list) |
| 116 | if self.time is not None: |
| 117 | self.recording[v].pop(0) |
| 118 | |
| 119 | def reset_state_variables(self) -> None: |
| 120 | # language=rst |