MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / expand_dims

Function expand_dims

ldm/models/diffusion/dpm_solver/dpm_solver.py:1145–1154  ·  view source on GitHub ↗

Expand the tensor `v` to the dim `dims`. Args: `v`: a PyTorch tensor with shape [N]. `dim`: a `int`. Returns: a PyTorch tensor with shape [N, 1, 1, ..., 1] and the total dimension is `dims`.

(v, dims)

Source from the content-addressed store, hash-verified

1143
1144
1145def expand_dims(v, dims):
1146 """
1147 Expand the tensor `v` to the dim `dims`.
1148 Args:
1149 `v`: a PyTorch tensor with shape [N].
1150 `dim`: a `int`.
1151 Returns:
1152 a PyTorch tensor with shape [N, 1, 1, ..., 1] and the total dimension is `dims`.
1153 """
1154 return v[(...,) + (None,) * (dims - 1)]

Calls

no outgoing calls

Tested by

no test coverage detected