@@ -46,6 +46,7 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
46
46
m = prepare_pt2e (m , quantizer )
47
47
# calibration
48
48
after_prepare_result = m (* example_inputs )
49
+ print ("pt2e prepare:" , m )
49
50
m = convert_pt2e (m )
50
51
after_quant_result = m (* example_inputs )
51
52
@@ -57,6 +58,7 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
57
58
m_copy , qconfig_mapping , example_inputs , backend_config = backend_config
58
59
)
59
60
after_prepare_result_fx = m_fx (* example_inputs )
61
+ print ("fx prepare:" , m_fx )
60
62
m_fx = _convert_to_reference_decomposed_fx (m_fx , backend_config = backend_config )
61
63
after_quant_result_fx = m_fx (* example_inputs )
62
64
@@ -69,10 +71,10 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
69
71
print ("m_fx:" , m_fx )
70
72
print ("prepare sqnr:" , compute_sqnr (after_prepare_result , after_prepare_result_fx ))
71
73
assert compute_sqnr (after_prepare_result , after_prepare_result_fx ) > 100
72
- print ("quant diff max:" , torch .max (after_quant_result - after_quant_result_fx ))
74
+ print ("diff max:" , torch .max (after_quant_result - after_quant_result_fx ))
75
+ print ("sqnr:" , compute_sqnr (after_quant_result , after_quant_result_fx ))
73
76
assert torch .max (after_quant_result - after_quant_result_fx ) < 1e-1
74
- print ("quant sqnr:" , compute_sqnr (after_quant_result , after_quant_result_fx ))
75
- assert compute_sqnr (after_quant_result , after_quant_result_fx ) > 30
77
+ assert compute_sqnr (after_quant_result , after_quant_result_fx ) > 35
76
78
77
79
78
80
if __name__ == "__main__" :
@@ -121,7 +123,7 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
121
123
raise RuntimeError (
122
124
f"Model { args .model_name } is not a valid name. or not quantizable right now, "
123
125
"please contact executorch team if you want to learn why or how to support "
124
- "quantization for the requested model"
126
+ "quantization for the requested model "
125
127
f"Available models are { list (MODEL_NAME_TO_OPTIONS .keys ())} ."
126
128
)
127
129
0 commit comments