MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / forward

Method forward

sat/vae_modules/cp_enc_dec.py:676–713  ·  view source on GitHub ↗
(self, x, temb, zq=None, clear_fake_cp_cache=True)

Source from the content-addressed store, hash-verified

674 )
675
676 def forward(self, x, temb, zq=None, clear_fake_cp_cache=True):
677 h = x
678
679 # if isinstance(self.norm1, torch.nn.GroupNorm):
680 # h = conv_gather_from_context_parallel_region(h, dim=2, kernel_size=1)
681 if zq is not None:
682 h = self.norm1(h, zq, clear_fake_cp_cache=clear_fake_cp_cache)
683 else:
684 h = self.norm1(h)
685 # if isinstance(self.norm1, torch.nn.GroupNorm):
686 # h = conv_scatter_to_context_parallel_region(h, dim=2, kernel_size=1)
687
688 h = nonlinearity(h)
689 h = self.conv1(h, clear_cache=clear_fake_cp_cache)
690
691 if temb is not None:
692 h = h + self.temb_proj(nonlinearity(temb))[:, :, None, None, None]
693
694 # if isinstance(self.norm2, torch.nn.GroupNorm):
695 # h = conv_gather_from_context_parallel_region(h, dim=2, kernel_size=1)
696 if zq is not None:
697 h = self.norm2(h, zq, clear_fake_cp_cache=clear_fake_cp_cache)
698 else:
699 h = self.norm2(h)
700 # if isinstance(self.norm2, torch.nn.GroupNorm):
701 # h = conv_scatter_to_context_parallel_region(h, dim=2, kernel_size=1)
702
703 h = nonlinearity(h)
704 h = self.dropout(h)
705 h = self.conv2(h, clear_cache=clear_fake_cp_cache)
706
707 if self.in_channels != self.out_channels:
708 if self.use_conv_shortcut:
709 x = self.conv_shortcut(x, clear_cache=clear_fake_cp_cache)
710 else:
711 x = self.nin_shortcut(x)
712
713 return x + h
714
715
716

Callers

nothing calls this directly

Calls 1

nonlinearityFunction · 0.70

Tested by

no test coverage detected