MCPcopy Index your code
hub / github.com/huggingface/diffusers / _to_cpu

Method _to_cpu

src/diffusers/hooks/group_offloading.py:176–180  ·  view source on GitHub ↗
(tensor, low_cpu_mem_usage)

Source from the content-addressed store, hash-verified

174
175 @staticmethod
176 def _to_cpu(tensor, low_cpu_mem_usage):
177 # For TorchAO tensors, `.data` returns an incomplete wrapper without internal attributes
178 # (e.g. `.qdata`, `.scale`), so we must call `.cpu()` on the tensor directly.
179 t = tensor.cpu() if _is_torchao_tensor(tensor) else tensor.data.cpu()
180 return t if low_cpu_mem_usage else t.pin_memory()
181
182 def _init_cpu_param_dict(self):
183 cpu_param_dict = {}

Callers 1

_init_cpu_param_dictMethod · 0.95

Calls 2

_is_torchao_tensorFunction · 0.85
pin_memoryMethod · 0.80

Tested by

no test coverage detected