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

Method __init__

sat/sgm/modules/autoencoding/magvit2_pytorch.py:810–833  ·  view source on GitHub ↗
(
        self, chan_in, chan_out, kernel_size: Union[int, Tuple[int, int, int]], pad_mode="constant", **kwargs
    )

Source from the content-addressed store, hash-verified

808class CausalConv3d(Module):
809 @beartype
810 def __init__(
811 self, chan_in, chan_out, kernel_size: Union[int, Tuple[int, int, int]], pad_mode="constant", **kwargs
812 ):
813 super().__init__()
814 kernel_size = cast_tuple(kernel_size, 3)
815
816 time_kernel_size, height_kernel_size, width_kernel_size = kernel_size
817
818 assert is_odd(height_kernel_size) and is_odd(width_kernel_size)
819
820 dilation = kwargs.pop("dilation", 1)
821 stride = kwargs.pop("stride", 1)
822
823 self.pad_mode = pad_mode
824 time_pad = dilation * (time_kernel_size - 1) + (1 - stride)
825 height_pad = height_kernel_size // 2
826 width_pad = width_kernel_size // 2
827
828 self.time_pad = time_pad
829 self.time_causal_padding = (width_pad, width_pad, height_pad, height_pad, time_pad, 0)
830
831 stride = (stride, 1, 1)
832 dilation = (dilation, 1, 1)
833 self.conv = nn.Conv3d(chan_in, chan_out, kernel_size, stride=stride, dilation=dilation, **kwargs)
834
835 def forward(self, x):
836 pad_mode = self.pad_mode if self.time_pad < x.shape[2] else "constant"

Callers

nothing calls this directly

Calls 3

cast_tupleFunction · 0.70
is_oddFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected