MCPcopy Create free account
hub / github.com/MeiGen-AI/MultiTalk / forward

Method forward

wan/modules/vae.py:202–220  ·  view source on GitHub ↗
(self, x, feat_cache=None, feat_idx=[0])

Source from the content-addressed store, hash-verified

200 if in_dim != out_dim else nn.Identity()
201
202 def forward(self, x, feat_cache=None, feat_idx=[0]):
203 h = self.shortcut(x)
204 for layer in self.residual:
205 if isinstance(layer, CausalConv3d) and feat_cache is not None:
206 idx = feat_idx[0]
207 cache_x = x[:, :, -CACHE_T:, :, :].clone()
208 if cache_x.shape[2] < 2 and feat_cache[idx] is not None:
209 # cache last frame of last two chunk
210 cache_x = torch.cat([
211 feat_cache[idx][:, :, -1, :, :].unsqueeze(2).to(
212 cache_x.device), cache_x
213 ],
214 dim=2)
215 x = layer(x, feat_cache[idx])
216 feat_cache[idx] = cache_x
217 feat_idx[0] += 1
218 else:
219 x = layer(x)
220 return x + h
221
222
223class AttentionBlock(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected