@@ -69,13 +69,10 @@ def set_quantization_configuration_to_graph(graph: Graph,
6969
7070 nodes_to_manipulate_activation_bit_widths = {} if bit_width_config is None else bit_width_config .get_nodes_to_manipulate_activation_bit_widths (graph )
7171 nodes_to_manipulate_weights_bit_widths = {} if bit_width_config is None else bit_width_config .get_nodes_to_manipulate_weights_bit_widths (graph )
72- print ('nodes_to_manipulate_weights_bit_widths:' , nodes_to_manipulate_weights_bit_widths )
7372
7473 for n in graph .nodes :
75- print ('n' , n )
7674 manual_bit_width_override = {ACTIVATION : nodes_to_manipulate_activation_bit_widths .get (n ),
7775 WEIGHTS : nodes_to_manipulate_weights_bit_widths .get (n )}
78- print ('manual_bit_width_override' , manual_bit_width_override )
7976 set_quantization_configs_to_node (node = n ,
8077 graph = graph ,
8178 quant_config = quant_config ,
@@ -171,20 +168,8 @@ def set_quantization_configs_to_node(node: BaseNode,
171168 mixed_precision_enable (bool): Whether mixed precision is enabled. Defaults to False.
172169 manual_bit_width_override (Optional[int]): Specifies a custom bit-width to override the node's activation bit-width. Defaults to None.
173170 """
174- a = node .get_node_weights_attributes ()
175- print ('a' , a )
176- b = node .candidates_quantization_cfg
177- print ('b' , b )
178171 node_qc_options = node .get_qco (fqc )
179- print ('8 node_qc_options' , node_qc_options )
180- print ('8' , type (node_qc_options .quantization_configurations ), len (node_qc_options .quantization_configurations ))
181- for ii , val in enumerate (node_qc_options .quantization_configurations ):
182- print ('8' , ii , type (val ), val .attr_weights_configs_mapping )
183- #print('8', node_qc_options.quantization_configurations[0].attr_weights_configs_mapping['kernel_attr'].weights_n_bits)
184172 base_config , node_qc_options_list = filter_node_qco_by_graph (node , fqc , graph , node_qc_options )
185- print ('9 base_config' , base_config )
186- print ('9 base_config.attr_weights_configs_mapping' , base_config .attr_weights_configs_mapping )
187- print ('9 node_qc_options_list' , len (node_qc_options_list ), node_qc_options_list )
188173
189174 # If a manual_bit_width_override is given, filter node_qc_options_list to retain only the options with activation bits equal to manual_bit_width_override,
190175 # and update base_config accordingly.
@@ -207,7 +192,7 @@ def set_quantization_configs_to_node(node: BaseNode,
207192 base_config ,
208193 node ,
209194 mixed_precision_enable = mixed_precision_enable )
210- #print('node.candidates_quantization_cfg', node.candidates_quantization_cfg)
195+
211196 # sorting the candidates by kernel attribute weights number of bits first and then by activation number of bits
212197 # (in reversed order). since only kernel attribute is quantized in weights mixed precision,
213198 # if the node doesn't have a kernel attribute, we only sort by activation_n_bits.
@@ -445,34 +430,22 @@ def filter_weights_qc_options_with_manual_bit_width(
445430 node_qc_options_weights_list = []
446431 override_attr , override_bitwidth = [], []
447432
448- print ('weights_manual_bit_width_override' , weights_manual_bit_width_override , type (weights_manual_bit_width_override ))
449433 for weights_manual_bit_width in weights_manual_bit_width_override :
450434 override_attr .append (weights_manual_bit_width [1 ])
451435 override_bitwidth .append (weights_manual_bit_width [0 ])
452436
453- print ('znq' , len (node_qc_options_list ), node_qc_options_list )
454- for ii , node_qc_options in enumerate (node_qc_options_list ):
455- print ('znq' , ii , node_qc_options .attr_weights_configs_mapping )
456- print ("zzz" , override_attr , override_bitwidth )
457437 node_qc_options_weights_list = copy .deepcopy (node_qc_options_list )
458- print ('yyy' , node_qc_options_weights_list )
459438 for attr , bitwidth in zip (override_attr , override_bitwidth ):
460- print ("aza" , attr , bitwidth )
461439 for op_cfg in node_qc_options_list :
462- print ("bbb" , op_cfg )
463440 if op_cfg in node_qc_options_weights_list :
464441 weights_attrs = op_cfg .attr_weights_configs_mapping .keys ()
465- print ('weights_attrs' , weights_attrs )
466442 if attr in weights_attrs :
467- print ('chk' , attr , weights_attrs )
468443 for weights_attr in weights_attrs :
469444 if attr == weights_attr and op_cfg .attr_weights_configs_mapping .get (attr ).weights_n_bits != bitwidth :
470445 node_qc_options_weights_list .remove (op_cfg )
471446 else :
472- print ('No weights attr' )
473447 node_qc_options_weights_list .remove (op_cfg )
474- print ('node_qc_options_weights_list' , node_qc_options_weights_list )
475- print ('0 base_config.attr_weights_configs_mapping' , base_config .attr_weights_configs_mapping )
448+
476449 if len (node_qc_options_weights_list ) == 0 :
477450 Logger .critical (f"Manually selected weights bit-width { weights_manual_bit_width_override } is invalid for node { node } ." )
478451 else :
@@ -482,24 +455,19 @@ def filter_weights_qc_options_with_manual_bit_width(
482455 updated_base_config = copy .deepcopy (base_config )
483456 for attr , bitwidth in zip (override_attr , override_bitwidth ):
484457 Logger .info (f"Setting node { node } bit-width to manually selected { attr } bit-width: { bitwidth } bits." )
485-
486- print ('node attr, bitwidth' , node , attr , bitwidth )
487458 updated_base_config = updated_base_config .clone_and_edit (attr_to_edit = {attr : {WEIGHTS_N_BITS : bitwidth }})
488- print ( 'updated_base_config' , updated_base_config )
459+
489460 if updated_base_config in node_qc_options_weights_list :
490461 # If a base_config with the specified weights_manual_bit_width_override exists in the node_qc_options_list,
491462 # point the base_config to this option.
492- print ('chk0000' )
493463 base_config = node_qc_options_weights_list [node_qc_options_weights_list .index (updated_base_config )]
494464 else :
495465 # Choose a different configuration from node_qc_options_list. If multiple options exist, issue a warning.
496- print ('chk0001' )
497466 base_config = node_qc_options_weights_list [0 ]
498467 if len (node_qc_options_weights_list ) > 0 and not mixed_precision_enable :
499468 Logger .info (
500469 f"Request received to select weights bit-widths { weights_manual_bit_width_override } ."
501470 f"However, the base configuration for layer type { node .type } is missing in the node_qc_options_list."
502471 f" Overriding base_config with an option that uses manually selected weights bit-widths { weights_manual_bit_width_override } ." ) # pragma: no cover
503- print ('1 base_config' , base_config )
504472
505473 return base_config , node_qc_options_weights_list
0 commit comments