Compute the intermediate time steps for sampling. Args: skip_type: A `str`. The type for the spacing of the time steps. We support three types: - 'logSNR': uniform logSNR for the time steps. - 'time_uniform': uniform time for the time steps. (**Re
(self, skip_type, t_T, t_0, N, device)
| 459 | return self.noise_prediction_fn(x, t) |
| 460 | |
| 461 | def get_time_steps(self, skip_type, t_T, t_0, N, device): |
| 462 | """Compute the intermediate time steps for sampling. |
| 463 | |
| 464 | Args: |
| 465 | skip_type: A `str`. The type for the spacing of the time steps. We support three types: |
| 466 | - 'logSNR': uniform logSNR for the time steps. |
| 467 | - 'time_uniform': uniform time for the time steps. (**Recommended for high-resolutional data**.) |
| 468 | - 'time_quadratic': quadratic time for the time steps. (Used in DDIM for low-resolutional data.) |
| 469 | t_T: A `float`. The starting time of the sampling (default is T). |
| 470 | t_0: A `float`. The ending time of the sampling (default is epsilon). |
| 471 | N: A `int`. The total number of the spacing of the time steps. |
| 472 | device: A torch device. |
| 473 | Returns: |
| 474 | A pytorch tensor of the time steps, with the shape (N + 1,). |
| 475 | """ |
| 476 | if skip_type == 'logSNR': |
| 477 | lambda_T = self.noise_schedule.marginal_lambda(torch.tensor(t_T).to(device)) |
| 478 | lambda_0 = self.noise_schedule.marginal_lambda(torch.tensor(t_0).to(device)) |
| 479 | logSNR_steps = torch.linspace(lambda_T.cpu().item(), lambda_0.cpu().item(), N + 1).to(device) |
| 480 | return self.noise_schedule.inverse_lambda(logSNR_steps) |
| 481 | elif skip_type == 'time_uniform': |
| 482 | return torch.linspace(t_T, t_0, N + 1).to(device) |
| 483 | elif skip_type == 'time_quadratic': |
| 484 | t_order = 2 |
| 485 | t = torch.linspace(t_T**(1. / t_order), t_0**(1. / t_order), N + 1).pow(t_order).to(device) |
| 486 | return t |
| 487 | else: |
| 488 | raise ValueError("Unsupported skip_type {}, need to be 'logSNR' or 'time_uniform' or 'time_quadratic'".format(skip_type)) |
| 489 | |
| 490 | def get_orders_and_timesteps_for_singlestep_solver(self, steps, order, skip_type, t_T, t_0, device): |
| 491 | """ |
no test coverage detected