4141
4242from executorch .backends .cortex_m .quantizer_reporter import (
4343 QuantizerReporter ,
44- SUPPORTED_QCONFIGS ,
4544 SUPPORTED_QSPECS ,
4645)
4746
@@ -219,20 +218,28 @@ def get_symmetric_quantization_config(
219218 bias_quantization_spec = _get_int32_bias_qspec
220219
221220 if is_dynamic :
222- quantization_config = TOSAQuantizationConfig (
223- act_quantization_spec ,
224- None ,
225- weight_quantization_spec ,
226- bias_quantization_spec ,
227- )
221+ output_activation = None
228222 else :
229- quantization_config = TOSAQuantizationConfig (
230- act_quantization_spec ,
231- act_quantization_spec ,
232- weight_quantization_spec ,
233- bias_quantization_spec ,
234- )
235- return quantization_config
223+ output_activation = act_quantization_spec
224+
225+ module_name = __name__ .rsplit ("." , maxsplit = 1 )[- 1 ]
226+ label = (
227+ f"{ module_name } .get_symmetric_quantization_config("
228+ f"per_channel={ int (is_per_channel )} , "
229+ f"qat={ int (is_qat )} , "
230+ f"dynamic={ int (is_dynamic )} , "
231+ f"act_range=[{ act_qmin } , { act_qmax } ], "
232+ f"weight_range=[{ weight_qmin } , { weight_qmax } ]"
233+ ")"
234+ )
235+
236+ return TOSAQuantizationConfig (
237+ act_quantization_spec ,
238+ output_activation ,
239+ weight_quantization_spec ,
240+ bias_quantization_spec ,
241+ label ,
242+ )
236243
237244
238245@functools .lru_cache
@@ -357,22 +364,31 @@ def get_symmetric_a16w8_quantization_config(
357364 is_qat = is_qat ,
358365 is_dynamic = is_dynamic ,
359366 )
360- # Replace activation quantization spec with 16-bit version
367+
361368 if is_dynamic :
362- quantization_config = TOSAQuantizationConfig (
363- act_quantization_spec , # 16-bit input activations
364- None ,
365- base_config .weight , # 8-bit weights from base config
366- base_config .bias , # bias from base config
367- )
369+ output_activation = None
368370 else :
369- quantization_config = TOSAQuantizationConfig (
370- act_quantization_spec , # 16-bit input activations
371- act_quantization_spec , # 16-bit output activations
372- base_config .weight , # 8-bit weights from base config
373- base_config .bias , # bias from base config
374- )
375- return quantization_config
371+ output_activation = act_quantization_spec
372+
373+ module_name = __name__ .rsplit ("." , maxsplit = 1 )[- 1 ]
374+ label = (
375+ f"{ module_name } .get_symmetric_a16w8_quantization_config("
376+ f"per_channel={ int (is_per_channel )} , "
377+ f"qat={ int (is_qat )} , "
378+ f"dynamic={ int (is_dynamic )} , "
379+ f"act_range=[{ act_quantization_spec .quant_min } , { act_quantization_spec .quant_max } ], "
380+ f"weight_range=[{ weight_qmin } , { weight_qmax } ]"
381+ ")"
382+ )
383+
384+ # Replace activation quantization spec with 16-bit version
385+ return TOSAQuantizationConfig (
386+ act_quantization_spec , # 16-bit input activations
387+ output_activation ,
388+ base_config .weight , # 8-bit weights from base config
389+ base_config .bias , # bias from base config
390+ label ,
391+ )
376392
377393
378394# Register supported quantization configs and qspecs in the reporter for human-readable reporting
@@ -389,16 +405,6 @@ def get_symmetric_a16w8_quantization_config(
389405_symmetric_a16w8_config_per_tensor = get_symmetric_a16w8_quantization_config (
390406 is_per_channel = False
391407)
392- SUPPORTED_QCONFIGS .update (
393- {
394- _symmetric_a8w8_config_per_channel : f"{ __name__ } .get_symmetric_quantization_config(is_per_channel=True)" ,
395- _symmetric_a16w8_config_per_channel : f"{ __name__ } .get_symmetric_a16w8_quantization_config(is_per_channel=True)" ,
396- _symmetric_a8w4_config_per_channel : f"{ __name__ } .get_symmetric_a8w4_quantization_config(is_per_channel=True)" ,
397- _symmetric_a8w8_config_per_tensor : f"{ __name__ } .get_symmetric_quantization_config(is_per_channel=False)" ,
398- _symmetric_a16w8_config_per_tensor : f"{ __name__ } .get_symmetric_a16w8_quantization_config(is_per_channel=False)" ,
399- _symmetric_a8w4_config_per_tensor : f"{ __name__ } .get_symmetric_a8w4_quantization_config(is_per_channel=False)" ,
400- }
401- )
402408
403409SUPPORTED_QSPECS .update (
404410 {
0 commit comments