From fd8d1c12d4e8f40f75b3d595c2e0fdfa8f8cca03 Mon Sep 17 00:00:00 2001 From: Sergey Borisov Date: Tue, 16 Jul 2024 00:43:32 +0300 Subject: [PATCH] Remove 'del' operator overload --- .../backend/stable_diffusion/denoise_context.py | 3 --- .../backend/stable_diffusion/diffusion_backend.py | 15 ++++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/invokeai/backend/stable_diffusion/denoise_context.py b/invokeai/backend/stable_diffusion/denoise_context.py index b56f095948..453398a121 100644 --- a/invokeai/backend/stable_diffusion/denoise_context.py +++ b/invokeai/backend/stable_diffusion/denoise_context.py @@ -55,6 +55,3 @@ class DenoiseContext: noise_pred: Optional[torch.Tensor] = None extra: dict = field(default_factory=dict) - - def __delattr__(self, name: str): - setattr(self, name, None) diff --git a/invokeai/backend/stable_diffusion/diffusion_backend.py b/invokeai/backend/stable_diffusion/diffusion_backend.py index 81fe00d59d..4c08639ddf 100644 --- a/invokeai/backend/stable_diffusion/diffusion_backend.py +++ b/invokeai/backend/stable_diffusion/diffusion_backend.py @@ -82,11 +82,11 @@ class StableDiffusionBackend: # compute the previous noisy sample x_t -> x_t-1 step_output = ctx.scheduler.step(ctx.noise_pred, ctx.timestep, ctx.latents, **ctx.scheduler_step_kwargs) - # del locals - del ctx.latent_model_input - del ctx.negative_noise_pred - del ctx.positive_noise_pred - del ctx.noise_pred + # clean up locals + ctx.latent_model_input = None + ctx.negative_noise_pred = None + ctx.positive_noise_pred = None + ctx.noise_pred = None return step_output @@ -126,8 +126,9 @@ class StableDiffusionBackend: ext_manager.callbacks.post_unet(ctx, ext_manager) - del ctx.unet_kwargs - del ctx.conditioning_mode + # clean up locals + ctx.unet_kwargs = None + ctx.conditioning_mode = None return noise_pred