model_utils.py 416 Bytes
Newer Older
1
2
3
4
5
# copied from https://github.com/qwopqwop200/GPTQ-for-LLaMa/blob/past/modelutils.py

import torch.nn as nn


6
def find_layers(module, layers=[nn.Conv2d, nn.Linear], name=""):
7
8
9
10
    if type(module) in layers:
        return {name: module}
    res = {}
    for name1, child in module.named_children():
11
        res.update(find_layers(child, layers=layers, name=name + "." + name1 if name != "" else name1))
12
    return res