mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-09 16:52:32 +08:00
wan: vae: free consumer caller tensors on recursion
This commit is contained in:
parent
45995ed76a
commit
8658c570f9
@ -391,7 +391,9 @@ class Decoder3d(nn.Module):
|
|||||||
x = layer(x)
|
x = layer(x)
|
||||||
out_chunks.append(x)
|
out_chunks.append(x)
|
||||||
|
|
||||||
def run_upsamples(layer_idx, x, feat_idx):
|
def run_upsamples(layer_idx, x_ref, feat_idx):
|
||||||
|
x = x_ref[0]
|
||||||
|
x_ref[0] = None
|
||||||
if layer_idx >= len(self.upsamples):
|
if layer_idx >= len(self.upsamples):
|
||||||
run_head(x, feat_idx)
|
run_head(x, feat_idx)
|
||||||
return
|
return
|
||||||
@ -401,9 +403,10 @@ class Decoder3d(nn.Module):
|
|||||||
for frame_idx in range(x.shape[2]):
|
for frame_idx in range(x.shape[2]):
|
||||||
run_upsamples(
|
run_upsamples(
|
||||||
layer_idx,
|
layer_idx,
|
||||||
x[:, :, frame_idx:frame_idx + 1, :, :],
|
[x[:, :, frame_idx:frame_idx + 1, :, :]],
|
||||||
feat_idx.copy(),
|
feat_idx.copy(),
|
||||||
)
|
)
|
||||||
|
del x
|
||||||
return
|
return
|
||||||
|
|
||||||
if feat_cache is not None:
|
if feat_cache is not None:
|
||||||
@ -411,9 +414,11 @@ class Decoder3d(nn.Module):
|
|||||||
else:
|
else:
|
||||||
x = layer(x)
|
x = layer(x)
|
||||||
|
|
||||||
run_upsamples(layer_idx + 1, x, feat_idx)
|
next_x_ref = [x]
|
||||||
|
del x
|
||||||
|
run_upsamples(layer_idx + 1, next_x_ref, feat_idx)
|
||||||
|
|
||||||
run_upsamples(0, x, feat_idx)
|
run_upsamples(0, [x], feat_idx)
|
||||||
return out_chunks
|
return out_chunks
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user