(
self,
hidden_states: torch.FloatTensor,
temb: Optional[torch.FloatTensor] = None,
image_only_indicator: Optional[torch.Tensor] = None,
)
| 716 | ) |
| 717 | |
| 718 | def forward( |
| 719 | self, |
| 720 | hidden_states: torch.FloatTensor, |
| 721 | temb: Optional[torch.FloatTensor] = None, |
| 722 | image_only_indicator: Optional[torch.Tensor] = None, |
| 723 | ): |
| 724 | num_frames = image_only_indicator.shape[-1] |
| 725 | hidden_states = self.spatial_res_block(hidden_states, temb) |
| 726 | |
| 727 | batch_frames, channels, height, width = hidden_states.shape |
| 728 | batch_size = batch_frames // num_frames |
| 729 | |
| 730 | hidden_states_mix = ( |
| 731 | hidden_states[None, :].reshape(batch_size, num_frames, channels, height, width).permute(0, 2, 1, 3, 4) |
| 732 | ) |
| 733 | hidden_states = ( |
| 734 | hidden_states[None, :].reshape(batch_size, num_frames, channels, height, width).permute(0, 2, 1, 3, 4) |
| 735 | ) |
| 736 | |
| 737 | if temb is not None: |
| 738 | temb = temb.reshape(batch_size, num_frames, -1) |
| 739 | |
| 740 | hidden_states = self.temporal_res_block(hidden_states, temb) |
| 741 | hidden_states = self.time_mixer( |
| 742 | x_spatial=hidden_states_mix, |
| 743 | x_temporal=hidden_states, |
| 744 | image_only_indicator=image_only_indicator, |
| 745 | ) |
| 746 | |
| 747 | hidden_states = hidden_states.permute(0, 2, 1, 3, 4).reshape(batch_frames, channels, height, width) |
| 748 | return hidden_states |
| 749 | |
| 750 | |
| 751 | class AlphaBlender(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected