(self, func)
| 112 | self._memory_profile_active = True |
| 113 | stack.append(self) |
| 114 | |
| 115 | def _end_memory_profile(self): |
| 116 | if not self._memory_profile_active: |
| 117 | return "" |
| 118 | |
| 119 | stack = _get_memory_profile_stack() |
| 120 | try: |
| 121 | peak_allocated, peak_reserved = self._read_memory_peak() |
| 122 | for context in stack: |
| 123 | context._record_memory_peak(peak_allocated, peak_reserved) |
| 124 | torch_device_module.reset_peak_memory_stats() |
| 125 | except (RuntimeError, NotImplementedError): |
| 126 | pass |
| 127 | finally: |
| 128 | if stack and stack[-1] is self: |
| 129 | stack.pop() |
| 130 | elif self in stack: |
| 131 | stack.remove(self) |
| 132 | self._memory_profile_active = False |
| 133 |
nothing calls this directly
no outgoing calls
no test coverage detected