(self, sample)
| 337 | |
| 338 | |
| 339 | def encode_small_video(self, sample): |
| 340 | B, C, T, H, W = sample.shape |
| 341 | computation_device = self.conv_in.weight.device |
| 342 | computation_dtype = self.conv_in.weight.dtype |
| 343 | value = [] |
| 344 | for i in range(T//8): |
| 345 | t = i*8 + T%2 - (T%2 and i==0) |
| 346 | t_ = i*8 + 8 + T%2 |
| 347 | model_input = sample[:, :, t: t_, :, :].to(dtype=computation_dtype, device=computation_device) |
| 348 | model_output = self.forward(model_input).to(dtype=sample.dtype, device=sample.device) |
| 349 | value.append(model_output) |
| 350 | value = torch.concat(value, dim=2) |
| 351 | for name, module in self.named_modules(): |
| 352 | if isinstance(module, CachedConv3d): |
| 353 | module.clear_cache() |
| 354 | return value |
| 355 | |
| 356 | |
| 357 | @staticmethod |
no test coverage detected