MCPcopy
hub / github.com/XPixelGroup/DiffBIR / append_dims

Function append_dims

diffbir/sampler/k_diffusion.py:10–15  ·  view source on GitHub ↗

Appends dimensions to the end of a tensor until it has target_dims dimensions.

(x, target_dims)

Source from the content-addressed store, hash-verified

8
9
10def append_dims(x, target_dims):
11 """Appends dimensions to the end of a tensor until it has target_dims dimensions."""
12 dims_to_append = target_dims - x.ndim
13 if dims_to_append < 0:
14 raise ValueError(f'input has {x.ndim} dims but target_dims is {target_dims}, which is less')
15 return x[(...,) + (None,) * dims_to_append]
16
17
18def append_zero(x):

Callers 2

to_dFunction · 0.85
denoiserMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected