| 1307 | return replacement_sources |
| 1308 | |
| 1309 | def __del__(self): |
| 1310 | # An explicitly destroyed engine can be garbage-collected after a new engine has wrapped the same model; |
| 1311 | # tearing it down again here would clear state that now belongs to the new engine. |
| 1312 | if getattr(self, "_destroyed", False): |
| 1313 | return |
| 1314 | try: |
| 1315 | self.destroy() |
| 1316 | except Exception as exc: |
| 1317 | # Avoid destructor-time exceptions for partially initialized engines. |
| 1318 | logger.debug("DeepSpeedEngine.__del__ cleanup skipped: %s", exc, exc_info=True) |
| 1319 | |
| 1320 | def destroy(self): |
| 1321 | self._destroyed = True |