(
self,
z: torch.Tensor,
*feat_cache: List[torch.Tensor]
)
| 145 | self.conv2 = CausalConv3d(self.z_dim, self.z_dim, 1) |
| 146 | |
| 147 | def forward( |
| 148 | self, |
| 149 | z: torch.Tensor, |
| 150 | *feat_cache: List[torch.Tensor] |
| 151 | ): |
| 152 | # from [batch_size, num_frames, num_channels, height, width] |
| 153 | # to [batch_size, num_channels, num_frames, height, width] |
| 154 | z = z.permute(0, 2, 1, 3, 4) |
| 155 | feat_cache = list(feat_cache) |
| 156 | print("Length of feat_cache: ", len(feat_cache)) |
| 157 | |
| 158 | device, dtype = z.device, z.dtype |
| 159 | scale = [self.mean.to(device=device, dtype=dtype), |
| 160 | 1.0 / self.std.to(device=device, dtype=dtype)] |
| 161 | |
| 162 | if isinstance(scale[0], torch.Tensor): |
| 163 | z = z / scale[1].view(1, self.z_dim, 1, 1, 1) + scale[0].view( |
| 164 | 1, self.z_dim, 1, 1, 1) |
| 165 | else: |
| 166 | z = z / scale[1] + scale[0] |
| 167 | iter_ = z.shape[2] |
| 168 | x = self.conv2(z) |
| 169 | for i in range(iter_): |
| 170 | if i == 0: |
| 171 | out, feat_cache = self.decoder( |
| 172 | x[:, :, i:i + 1, :, :], |
| 173 | feat_cache=feat_cache) |
| 174 | else: |
| 175 | out_, feat_cache = self.decoder( |
| 176 | x[:, :, i:i + 1, :, :], |
| 177 | feat_cache=feat_cache) |
| 178 | out = torch.cat([out, out_], 2) |
| 179 | |
| 180 | out = out.float().clamp_(-1, 1) |
| 181 | # from [batch_size, num_channels, num_frames, height, width] |
| 182 | # to [batch_size, num_frames, num_channels, height, width] |
| 183 | out = out.permute(0, 2, 1, 3, 4) |
| 184 | return out, feat_cache |
| 185 | |
| 186 | |
| 187 | class VAEDecoder3d(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected