(self, argument)
| 383 | self.non_tensor = {} |
| 384 | |
| 385 | def offload(self, argument): |
| 386 | |
| 387 | def is_base_tensor(tensor): |
| 388 | return torch.is_tensor(a) and not a._is_view() and not hasattr(tensor, "ds_id") |
| 389 | |
| 390 | base_tensor_ids = set() |
| 391 | for a in argument: |
| 392 | if is_base_tensor(a): |
| 393 | base_tensor_ids.add(id(a)) |
| 394 | |
| 395 | for a in argument: |
| 396 | a_id = id(a) |
| 397 | |
| 398 | if is_base_tensor(a): |
| 399 | # Base tensor |
| 400 | self.devices[a_id] = a.device |
| 401 | self.base_tensors[a_id] = a |
| 402 | else: |
| 403 | # other types or ds tensor |
| 404 | self.non_tensor[a_id] = a |
| 405 | |
| 406 | self.arg_list.append(a_id) |
| 407 | |
| 408 | for a in argument: |
| 409 | if is_base_tensor(a): |
| 410 | a.data = a.data.to("cpu") |
| 411 | |
| 412 | def reload(self, in_place): |
| 413 |
no test coverage detected