(module, names, name='', groupsize=-1, double_groupsize=-1, bits=4, v1=True, asym=True)
| 97 | |
| 98 | |
| 99 | def make_quant(module, names, name='', groupsize=-1, double_groupsize=-1, bits=4, v1=True, asym=True): |
| 100 | if isinstance(module, QuantLinear): |
| 101 | return |
| 102 | for attr in dir(module): |
| 103 | tmp = getattr(module, attr) |
| 104 | name1 = name + '.' + attr if name != '' else attr |
| 105 | if name1 in names: |
| 106 | setattr( |
| 107 | module, attr, QuantLinear(tmp.in_features, tmp.out_features, groupsize=groupsize, double_groupsize=double_groupsize, bits=bits, v1=v1, asym=asym) |
| 108 | ) |
| 109 | for name1, child in module.named_children(): |
| 110 | make_quant(child, names, name + '.' + name1 if name != '' else name1, groupsize=groupsize, double_groupsize=double_groupsize, bits=bits, v1=v1, asym=asym) |
| 111 | |
| 112 | |
| 113 | def model_to_half(model): |
no test coverage detected