| 189 | module.to_cpu(non_blocking=True) |
| 190 | |
| 191 | def to_cuda_async(self, non_blocking=True): |
| 192 | for name, param in self._parameters.items(): |
| 193 | if param is not None: |
| 194 | if hasattr(param, "cuda"): |
| 195 | self._parameters[name] = param.to(AI_DEVICE, non_blocking=non_blocking) |
| 196 | elif hasattr(param, "to_cuda"): |
| 197 | self._parameters[name].to_cuda(non_blocking=True) |
| 198 | setattr(self, name, self._parameters[name]) |
| 199 | for module in self._modules.values(): |
| 200 | if isinstance(module, WeightModuleList): |
| 201 | for i in range(len(module)): |
| 202 | for m in module[i]._modules.values(): |
| 203 | if m is not None and hasattr(m, "to_cuda"): |
| 204 | m.to_cuda(non_blocking=True) |
| 205 | for m in module[i]._parameters.values(): |
| 206 | if m is not None and hasattr(m, "to_cuda"): |
| 207 | m.to_cuda(non_blocking=True) |
| 208 | else: |
| 209 | if module is not None and hasattr(module, "to_cuda"): |
| 210 | module.to_cuda(non_blocking=True) |
| 211 | |
| 212 | |
| 213 | class WeightModuleList(WeightModule): |
| 214 | def __init__(self, modules=None): |
| 215 | super().__init__() |
| 216 | self._list = [] |
| 217 | if modules is not None: |
| 218 | for idx, module in enumerate(modules): |
no outgoing calls
no test coverage detected