MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / append_dims

Function append_dims

sat/sgm/util.py:278–283  ·  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

276
277
278def append_dims(x, target_dims):
279 """Appends dimensions to the end of a tensor until it has target_dims dimensions."""
280 dims_to_append = target_dims - x.ndim
281 if dims_to_append < 0:
282 raise ValueError(f"input has {x.ndim} dims but target_dims is {target_dims}, which is less")
283 return x[(...,) + (None,) * dims_to_append]
284
285
286def load_model_from_config(config, ckpt, verbose=True, freeze=True):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected