Function to reshape the vector by the number of dimensions of x. E.g. x (bs, c, h, w), v (bs) -> v (bs, 1, 1, 1).
(v_, x_)
| 23 | |
| 24 | |
| 25 | def pad_v_like_x(v_, x_): |
| 26 | """ |
| 27 | Function to reshape the vector by the number of dimensions |
| 28 | of x. E.g. x (bs, c, h, w), v (bs) -> v (bs, 1, 1, 1). |
| 29 | """ |
| 30 | if isinstance(v_, float): |
| 31 | return v_ |
| 32 | return v_.reshape(-1, *([1] * (x_.ndim - 1))) |
| 33 | |
| 34 | |
| 35 | def forward_with_cfg(x, t, model, cfg_scale=1.0, uc_cond=None, cond_key="y", **model_kwargs): |
no outgoing calls
no test coverage detected