| 1254 | return replacement_sources |
| 1255 | |
| 1256 | def __del__(self): |
| 1257 | # An explicitly destroyed engine can be garbage-collected after a new engine has wrapped the same model; |
| 1258 | # tearing it down again here would clear state that now belongs to the new engine. |
| 1259 | if getattr(self, "_destroyed", False): |
| 1260 | return |
| 1261 | try: |
| 1262 | self.destroy() |
| 1263 | except Exception as exc: |
| 1264 | # Avoid destructor-time exceptions for partially initialized engines. |
| 1265 | logger.debug("DeepSpeedEngine.__del__ cleanup skipped: %s", exc, exc_info=True) |
| 1266 | |
| 1267 | def destroy(self): |
| 1268 | self._destroyed = True |