@@ -75,12 +75,10 @@ def generate_quantization_parameters(
7575 if model_qsvs is None :
7676 model_qsvs = {}
7777
78- skip_subgraphs = set ()
78+ float_subgraphs = set ()
7979 op_codes = self .flatbuffer_model .operatorCodes
8080 for sg_ind , subgraph in enumerate (self .flatbuffer_model .subgraphs ):
81- if sg_ind in skip_subgraphs :
82- continue
83-
81+ no_quantize_this_subgraph = sg_ind in float_subgraphs
8482 graph_info = qtyping .GraphInfo (
8583 subgraph .tensors , self .flatbuffer_model .buffers
8684 )
@@ -109,14 +107,20 @@ def generate_quantization_parameters(
109107 algorithm_name , op_quant_config = (
110108 model_recipe_manager .get_quantization_configs (op_key , op_scope )
111109 )
112- if policy .is_non_quantizable_composite_op (op ):
110+ if (
111+ policy .is_non_quantizable_composite_op (op )
112+ or no_quantize_this_subgraph
113+ ):
113114 algorithm_name = algorithm_manager .AlgorithmName .NO_QUANTIZE
114115
115116 if algorithm_name == algorithm_manager .AlgorithmName .NO_QUANTIZE :
116- side_effect_subgraphs = (
117- tfl_flatbuffer_utils .get_op_side_effect_subgraphs (op )
118- )
119- skip_subgraphs .update (side_effect_subgraphs )
117+ # Add side effect subgraphs to the float subgraphs
118+ # if the op is not no quantized.
119+ if not no_quantize_this_subgraph :
120+ side_effect_subgraphs = (
121+ tfl_flatbuffer_utils .get_op_side_effect_subgraphs (op )
122+ )
123+ float_subgraphs .update (side_effect_subgraphs )
120124
121125 op_quant_results = self ._get_params_for_no_quant_op (
122126 subgraph_op_id , op , subgraph .tensors
0 commit comments