(
self,
hidden_states: torch.Tensor,
temb: Optional[torch.Tensor] = None,
image_only_indicator: Optional[torch.Tensor] = None,
)
| 684 | ) |
| 685 | |
| 686 | def forward( |
| 687 | self, |
| 688 | hidden_states: torch.Tensor, |
| 689 | temb: Optional[torch.Tensor] = None, |
| 690 | image_only_indicator: Optional[torch.Tensor] = None, |
| 691 | ): |
| 692 | num_frames = image_only_indicator.shape[-1] |
| 693 | hidden_states = self.spatial_res_block(hidden_states, temb) |
| 694 | |
| 695 | batch_frames, channels, height, width = hidden_states.shape |
| 696 | batch_size = batch_frames // num_frames |
| 697 | |
| 698 | hidden_states_mix = ( |
| 699 | hidden_states[None, :].reshape(batch_size, num_frames, channels, height, width).permute(0, 2, 1, 3, 4) |
| 700 | ) |
| 701 | hidden_states = ( |
| 702 | hidden_states[None, :].reshape(batch_size, num_frames, channels, height, width).permute(0, 2, 1, 3, 4) |
| 703 | ) |
| 704 | |
| 705 | if temb is not None: |
| 706 | temb = temb.reshape(batch_size, num_frames, -1) |
| 707 | |
| 708 | hidden_states = self.temporal_res_block(hidden_states, temb) |
| 709 | hidden_states = self.time_mixer( |
| 710 | x_spatial=hidden_states_mix, |
| 711 | x_temporal=hidden_states, |
| 712 | image_only_indicator=image_only_indicator, |
| 713 | ) |
| 714 | |
| 715 | hidden_states = hidden_states.permute(0, 2, 1, 3, 4).reshape(batch_frames, channels, height, width) |
| 716 | return hidden_states |
| 717 | |
| 718 | |
| 719 | class AlphaBlender(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected