MCPcopy Create free account
hub / github.com/UVA-Computer-Vision-Lab/FrameINO / forward

Method forward

architecture/autoencoder_kl_wan.py:586–623  ·  view source on GitHub ↗
(self, x, feat_cache=None, feat_idx=[0])

Source from the content-addressed store, hash-verified

584 self.gradient_checkpointing = False
585
586 def forward(self, x, feat_cache=None, feat_idx=[0]):
587 if feat_cache is not None:
588 idx = feat_idx[0]
589 cache_x = x[:, :, -CACHE_T:, :, :].clone()
590 if cache_x.shape[2] < 2 and feat_cache[idx] is not None:
591 # cache last frame of last two chunk
592 cache_x = torch.cat([feat_cache[idx][:, :, -1, :, :].unsqueeze(2).to(cache_x.device), cache_x], dim=2)
593 x = self.conv_in(x, feat_cache[idx])
594 feat_cache[idx] = cache_x
595 feat_idx[0] += 1
596 else:
597 x = self.conv_in(x)
598
599 ## downsamples
600 for layer in self.down_blocks:
601 if feat_cache is not None:
602 x = layer(x, feat_cache, feat_idx)
603 else:
604 x = layer(x)
605
606 ## middle
607 x = self.mid_block(x, feat_cache, feat_idx)
608
609 ## head
610 x = self.norm_out(x)
611 x = self.nonlinearity(x)
612 if feat_cache is not None:
613 idx = feat_idx[0]
614 cache_x = x[:, :, -CACHE_T:, :, :].clone()
615 if cache_x.shape[2] < 2 and feat_cache[idx] is not None:
616 # cache last frame of last two chunk
617 cache_x = torch.cat([feat_cache[idx][:, :, -1, :, :].unsqueeze(2).to(cache_x.device), cache_x], dim=2)
618 x = self.conv_out(x, feat_cache[idx])
619 feat_cache[idx] = cache_x
620 feat_idx[0] += 1
621 else:
622 x = self.conv_out(x)
623 return x
624
625
626class WanResidualUpBlock(nn.Module):

Callers

nothing calls this directly

Calls 1

toMethod · 0.45

Tested by

no test coverage detected