(
self,
*,
ch,
out_ch,
ch_mult=(1, 2, 4, 8),
num_res_blocks,
attn_resolutions,
dropout=0.0,
resamp_with_conv=True,
in_channels,
resolution,
z_channels,
double_z=True,
pad_mode="first",
temporal_compress_times=4,
gather_norm=False,
**ignore_kwargs,
)
| 619 | |
| 620 | class ContextParallelEncoder3D(nn.Module): |
| 621 | def __init__( |
| 622 | self, |
| 623 | *, |
| 624 | ch, |
| 625 | out_ch, |
| 626 | ch_mult=(1, 2, 4, 8), |
| 627 | num_res_blocks, |
| 628 | attn_resolutions, |
| 629 | dropout=0.0, |
| 630 | resamp_with_conv=True, |
| 631 | in_channels, |
| 632 | resolution, |
| 633 | z_channels, |
| 634 | double_z=True, |
| 635 | pad_mode="first", |
| 636 | temporal_compress_times=4, |
| 637 | gather_norm=False, |
| 638 | **ignore_kwargs, |
| 639 | ): |
| 640 | super().__init__() |
| 641 | self.ch = ch |
| 642 | self.temb_ch = 0 |
| 643 | self.num_resolutions = len(ch_mult) |
| 644 | self.num_res_blocks = num_res_blocks |
| 645 | self.resolution = resolution |
| 646 | self.in_channels = in_channels |
| 647 | |
| 648 | # log2 of temporal_compress_times |
| 649 | self.temporal_compress_level = int(np.log2(temporal_compress_times)) |
| 650 | |
| 651 | self.conv_in = ContextParallelCausalConv3d( |
| 652 | chan_in=in_channels, |
| 653 | chan_out=self.ch, |
| 654 | kernel_size=3, |
| 655 | ) |
| 656 | |
| 657 | curr_res = resolution |
| 658 | in_ch_mult = (1,) + tuple(ch_mult) |
| 659 | self.down = nn.ModuleList() |
| 660 | for i_level in range(self.num_resolutions): |
| 661 | block = nn.ModuleList() |
| 662 | attn = nn.ModuleList() |
| 663 | block_in = ch * in_ch_mult[i_level] |
| 664 | block_out = ch * ch_mult[i_level] |
| 665 | for i_block in range(self.num_res_blocks): |
| 666 | block.append( |
| 667 | ContextParallelResnetBlock3D( |
| 668 | in_channels=block_in, |
| 669 | out_channels=block_out, |
| 670 | dropout=dropout, |
| 671 | temb_channels=self.temb_ch, |
| 672 | gather_norm=gather_norm, |
| 673 | ) |
| 674 | ) |
| 675 | block_in = block_out |
| 676 | down = nn.Module() |
| 677 | down.block = block |
| 678 | down.attn = attn |
nothing calls this directly
no test coverage detected