@@ -212,39 +212,40 @@ def _proportion_str(num_weights_list: List[int], total_num_weights: int, total_n
212
212
return f"{ percentage :.0f} % ({ len (num_weights_list )} / { total_num_params } )"
213
213
214
214
def _get_bitwidth_distribution_str (
215
- self , all_params : List [WeightCompressionParameters ], internal_params : List [WeightCompressionParameters ]
215
+ self , all_params : List [WeightCompressionParameters ], ratio_defining_params : List [WeightCompressionParameters ]
216
216
) -> str :
217
217
"""
218
218
Generates a table that shows the ratio of weights quantized to different number of bits.
219
219
220
- :param all_params: List of information about each weight node.
221
- :param internal_params: List of information about weight nodes that are considered for mixed precision.
220
+ :param all_params: Information about each weight node.
221
+ :param ratio_defining_params: Information about weights that are used for calculating ratio between primary and
222
+ backup precisions.
222
223
:return: A string containing the table.
223
224
"""
224
225
num_bits_vs_num_weights_map = {}
225
- internal_weight_names = set (wp .weight_name for wp in internal_params )
226
+ ratio_defining_weight_names = set (wp .weight_name for wp in ratio_defining_params )
226
227
for data in all_params :
227
228
num_bits = data .compression_config .num_bits
228
- n_total , n_internal = num_bits_vs_num_weights_map .get (num_bits , ([], []))
229
- if data .weight_name in internal_weight_names :
230
- n_internal .append (data .num_weights )
229
+ n_total , n_ratio_defining = num_bits_vs_num_weights_map .get (num_bits , ([], []))
230
+ if data .weight_name in ratio_defining_weight_names :
231
+ n_ratio_defining .append (data .num_weights )
231
232
n_total .append (data .num_weights )
232
- num_bits_vs_num_weights_map [num_bits ] = (n_total , n_internal )
233
+ num_bits_vs_num_weights_map [num_bits ] = (n_total , n_ratio_defining )
233
234
234
- num_internal_weights = sum (ws .num_weights for ws in internal_params )
235
- num_internal_params = len (internal_params )
235
+ num_ratio_defining_weights = sum (ws .num_weights for ws in ratio_defining_params )
236
+ num_ratio_defining_params = len (ratio_defining_params )
236
237
num_total_weights = sum (ws .num_weights for ws in all_params )
237
238
num_params = len (all_params )
238
239
num_bits_vs_num_weights_map = OrderedDict (sorted (num_bits_vs_num_weights_map .items (), reverse = True ))
239
240
# Table creation
240
- header = ["Num bits (N)" , "% all parameters (layers)" , "% internal parameters (layers)" ]
241
+ header = ["Num bits (N)" , "% all parameters (layers)" , "% ratio-defining parameters (layers)" ]
241
242
rows = []
242
- for bitwidth , (n_total , n_internal ) in num_bits_vs_num_weights_map .items ():
243
+ for bitwidth , (n_total , n_ratio_defining ) in num_bits_vs_num_weights_map .items ():
243
244
rows .append (
244
245
[
245
246
bitwidth ,
246
247
self ._proportion_str (n_total , num_total_weights , num_params ),
247
- self ._proportion_str (n_internal , num_internal_weights , num_internal_params ),
248
+ self ._proportion_str (n_ratio_defining , num_ratio_defining_weights , num_ratio_defining_params ),
248
249
]
249
250
)
250
251
0 commit comments