This repository was archived by the owner on Sep 10, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 2323from __future__ import annotations
2424
2525import json
26+ import types
2627
2728# from functools import reduce
2829# from math import gcd
3233import torch .nn as nn
3334import torch .nn .functional as F
3435
36+ from torchao .quantization .quant_api import _linear_extra_repr
37+
3538# AttributeError: '_OpNamespace' 'quantized_decomposed' object has no attribute 'quantize_per_channel_group'
3639from torch .ao .quantization .fx ._decomposed import quantized_decomposed_lib # noqa
3740from torchao .dtypes import PackedLinearInt8DynamicActivationIntxWeightLayout , QDQLayout
@@ -111,6 +114,16 @@ def quantize_model(
111114 if isinstance (quantize_options , str ):
112115 quantize_options = json .loads (quantize_options )
113116
117+ def _attach_extra_repr (module ):
118+ for name , child in module .named_children ():
119+ if isinstance (child , nn .Linear ):
120+ if not hasattr (child , 'extra_repr' ):
121+ child .extra_repr = types .MethodType (_linear_extra_repr , child )
122+ else :
123+ _attach_extra_repr (child )
124+
125+ _attach_extra_repr (model )
126+
114127 for quantizer , q_kwargs in quantize_options .items ():
115128 if quantizer not in quantizer_class_dict :
116129 raise RuntimeError (f"unknown quantizer { quantizer } specified" )
You can’t perform that action at this time.
0 commit comments