File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
neural_compressor/adaptor/torch_utils/waq Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ def __init__(
5656 alpha_step = 0.1 ,
5757 shared_criterion = "mean" ,
5858 init_alpha = 0.5 ,
59+ folding = False ,
5960 do_blockwise = False ,
6061 n_samples = 32 ,
6162 ):
@@ -75,6 +76,7 @@ def __init__(
7576 self .absorb_to_layer = absorb_to_layer
7677 self .weight_scale_dict = {}
7778 self .q_func = q_func
79+ self .folding = folding
7880 self .example_inputs = example_inputs
7981 self .max_value_info = {} # to record max values for alpha tune
8082 self .weight_clip = weight_clip [0 ] if isinstance (weight_clip , tuple ) else weight_clip
@@ -92,9 +94,10 @@ def tune(self):
9294 for key in self .input_mins .keys ():
9395 self .input_maxes_abs [key ] = torch .max (torch .abs (self .input_mins [key ]), torch .abs (self .input_maxes [key ]))
9496
95- diff_modules = set (self .absorb_to_layer .keys ()).difference (self .input_mins .keys ())
96- for d in diff_modules :
97- del self .absorb_to_layer [d ]
97+ if not self .folding :
98+ diff_modules = set (self .absorb_to_layer .keys ()).difference (self .input_mins .keys ())
99+ for d in diff_modules :
100+ del self .absorb_to_layer [d ]
98101
99102 scale_memo_use = 0
100103 for key in self .absorb_to_layer :
Original file line number Diff line number Diff line change @@ -452,6 +452,7 @@ def transform(
452452 op_types = op_types ,
453453 device = self .device ,
454454 q_func = self .q_func ,
455+ folding = folding ,
455456 example_inputs = self .example_inputs ,
456457 ** auto_alpha_args ,
457458 )
You can’t perform that action at this time.
0 commit comments