Skip to content

Commit

Permalink
Fix deletion of ctx tensors in LPC class
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyolicoris committed Apr 25, 2024
1 parent 7da81c9 commit bcdfebf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion torchlpc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ def backward(
unfolded_y = padded_y.unfold(1, order, 1).flip(2)
grad_A = unfolded_y * -flipped_grad_x.flip(1).unsqueeze(2)

del ctx.y, ctx.A, ctx.zi
if hasattr(ctx, "y"):
del ctx.y
if hasattr(ctx, "A"):
del ctx.A
if hasattr(ctx, "zi"):
del ctx.zi
return grad_x, grad_A, grad_zi

@staticmethod
Expand Down

0 comments on commit bcdfebf

Please sign in to comment.