MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / forward

Method forward

diffsynth/models/wan_video_vae.py:215–233  ·  view source on GitHub ↗
(self, x, feat_cache=None, feat_idx=[0])

Source from the content-addressed store, hash-verified

213 if in_dim != out_dim else nn.Identity()
214
215 def forward(self, x, feat_cache=None, feat_idx=[0]):
216 h = self.shortcut(x)
217 for layer in self.residual:
218 if check_is_instance(layer, CausalConv3d) and feat_cache is not None:
219 idx = feat_idx[0]
220 cache_x = x[:, :, -CACHE_T:, :, :].clone()
221 if cache_x.shape[2] < 2 and feat_cache[idx] is not None:
222 # cache last frame of last two chunk
223 cache_x = torch.cat([
224 feat_cache[idx][:, :, -1, :, :].unsqueeze(2).to(
225 cache_x.device), cache_x
226 ],
227 dim=2)
228 x = layer(x, feat_cache[idx])
229 feat_cache[idx] = cache_x
230 feat_idx[0] += 1
231 else:
232 x = layer(x)
233 return x + h
234
235
236class AttentionBlock(nn.Module):

Callers

nothing calls this directly

Calls 2

check_is_instanceFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected