(
self,
hidden_states: torch.FloatTensor,
res_hidden_states_tuple: Tuple[torch.FloatTensor, ...],
temb: Optional[torch.FloatTensor] = None,
upsample_size: Optional[int] = None,
num_frames: int = 1,
)
| 885 | self.resolution_idx = resolution_idx |
| 886 | |
| 887 | def forward( |
| 888 | self, |
| 889 | hidden_states: torch.FloatTensor, |
| 890 | res_hidden_states_tuple: Tuple[torch.FloatTensor, ...], |
| 891 | temb: Optional[torch.FloatTensor] = None, |
| 892 | upsample_size: Optional[int] = None, |
| 893 | num_frames: int = 1, |
| 894 | ) -> torch.FloatTensor: |
| 895 | is_freeu_enabled = ( |
| 896 | getattr(self, "s1", None) |
| 897 | and getattr(self, "s2", None) |
| 898 | and getattr(self, "b1", None) |
| 899 | and getattr(self, "b2", None) |
| 900 | ) |
| 901 | for resnet, temp_conv in zip(self.resnets, self.temp_convs): |
| 902 | # pop res hidden states |
| 903 | res_hidden_states = res_hidden_states_tuple[-1] |
| 904 | res_hidden_states_tuple = res_hidden_states_tuple[:-1] |
| 905 | |
| 906 | # FreeU: Only operate on the first two stages |
| 907 | if is_freeu_enabled: |
| 908 | hidden_states, res_hidden_states = apply_freeu( |
| 909 | self.resolution_idx, |
| 910 | hidden_states, |
| 911 | res_hidden_states, |
| 912 | s1=self.s1, |
| 913 | s2=self.s2, |
| 914 | b1=self.b1, |
| 915 | b2=self.b2, |
| 916 | ) |
| 917 | |
| 918 | hidden_states = torch.cat([hidden_states, res_hidden_states], dim=1) |
| 919 | |
| 920 | hidden_states = resnet(hidden_states, temb) |
| 921 | hidden_states = temp_conv(hidden_states, num_frames=num_frames) |
| 922 | |
| 923 | if self.upsamplers is not None: |
| 924 | for upsampler in self.upsamplers: |
| 925 | hidden_states = upsampler(hidden_states, upsample_size) |
| 926 | |
| 927 | return hidden_states |
| 928 | |
| 929 | |
| 930 | class DownBlockMotion(nn.Module): |
nothing calls this directly
no test coverage detected