MCPcopy Index your code
hub / github.com/CompVis/diff2flow / pad_v_like_x

Function pad_v_like_x

diff2flow/flow.py:25–32  ·  view source on GitHub ↗

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_)

Source from the content-addressed store, hash-verified

23
24
25def 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
35def forward_with_cfg(x, t, model, cfg_scale=1.0, uc_cond=None, cond_key="y", **model_kwargs):

Callers 7

compute_driftMethod · 0.85
compute_diffusionMethod · 0.85
compute_xtMethod · 0.85
compute_utMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected