(module, target_device)
| 50 | |
| 51 | |
| 52 | def compress_module(module, target_device): |
| 53 | for attr_str in dir(module): |
| 54 | target_attr = getattr(module, attr_str) |
| 55 | if type(target_attr) == torch.nn.Linear: |
| 56 | setattr( |
| 57 | module, |
| 58 | attr_str, |
| 59 | CLinear(target_attr.weight, target_attr.bias, target_device), |
| 60 | ) |
| 61 | for name, child in module.named_children(): |
| 62 | compress_module(child, target_device) |
| 63 | |
| 64 | |
| 65 | def get_compressed_list(module, prefix=""): |