(self, non_blocking=False)
| 101 | yield from module.named_parameters(prefix + name + ".") |
| 102 | |
| 103 | def to_cpu(self, non_blocking=False): |
| 104 | for name, param in self._parameters.items(): |
| 105 | if param is not None: |
| 106 | if hasattr(param, "cpu"): |
| 107 | self._parameters[name] = param.to("cpu", non_blocking=non_blocking) |
| 108 | setattr(self, name, self._parameters[name]) |
| 109 | elif hasattr(param, "to_cpu"): |
| 110 | self._parameters[name].to_cpu() |
| 111 | setattr(self, name, self._parameters[name]) |
| 112 | for module in self._modules.values(): |
| 113 | if isinstance(module, WeightModuleList): |
| 114 | for i in range(len(module)): |
| 115 | for m in module[i]._modules.values(): |
| 116 | if m is not None and hasattr(m, "to_cpu"): |
| 117 | m.to_cpu() |
| 118 | for m in module[i]._parameters.values(): |
| 119 | if m is not None and hasattr(m, "to_cpu"): |
| 120 | m.to_cpu() |
| 121 | else: |
| 122 | if module is not None and hasattr(module, "to_cpu"): |
| 123 | module.to_cpu() |
| 124 | |
| 125 | def to_cuda(self, non_blocking=False): |
| 126 | """Move parameters to GPU device (supports cuda/intel xpu)""" |
no test coverage detected