mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-10-03 17:15:19 -07:00
refactor(generation): simplify post-generation cache cleanup
Initialise tts_model before the try so the finally can read its device without a locals() probe, import empty_device_cache alongside the other backend imports instead of inside a bare try/except, and flatten the MPS branch in empty_device_cache.
This commit is contained in:
committed by
capy-ai-staging[bot]
parent
38389db82b
commit
17fd1ddd1b
@@ -219,9 +219,8 @@ def empty_device_cache(device: str) -> None:
|
||||
torch.cuda.empty_cache()
|
||||
elif device == "xpu" and hasattr(torch, "xpu"):
|
||||
torch.xpu.empty_cache()
|
||||
elif device == "mps" and hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
|
||||
if hasattr(torch.mps, "empty_cache"):
|
||||
torch.mps.empty_cache()
|
||||
elif device == "mps" and torch.backends.mps.is_available() and hasattr(torch.mps, "empty_cache"):
|
||||
torch.mps.empty_cache()
|
||||
|
||||
|
||||
def manual_seed(seed: int, device: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user