in fastchat/model/compression.py [0:0]
def get_compressed_list(module, prefix=""):
compressed_list = []
for attr_str in dir(module):
target_attr = getattr(module, attr_str)
if type(target_attr) == torch.nn.Linear:
full_name = (
f"{prefix}.{attr_str}.weight" if prefix else f"{attr_str}.weight"
)
compressed_list.append(full_name)
for name, child in module.named_children():
child_prefix = f"{prefix}.{name}" if prefix else name
for each in get_compressed_list(child, child_prefix):
compressed_list.append(each)
return compressed_list