MCPcopy Create free account
hub / github.com/Sin3DM/Sin3DM / _WrappedModel

Class _WrappedModel

src/diffusion/respace.py:116–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114
115
116class _WrappedModel:
117 def __init__(self, model, timestep_map, rescale_timesteps, original_num_steps):
118 self.model = model
119 self.timestep_map = timestep_map
120 self.rescale_timesteps = rescale_timesteps
121 self.original_num_steps = original_num_steps
122
123 def __call__(self, x, ts, **kwargs):
124 map_tensor = th.tensor(self.timestep_map, device=ts.device, dtype=ts.dtype)
125 new_ts = map_tensor[ts]
126 if self.rescale_timesteps:
127 new_ts = new_ts.float() * (1000.0 / self.original_num_steps)
128 return self.model(x, new_ts, **kwargs)

Callers 1

_wrap_modelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected