@@ -62,21 +62,27 @@ def read_ref_fq_params(q_group, q_config, narrow_range, hf_range):
62
62
return ref_quantize_params
63
63
64
64
65
- def dump_fq_params (fq_params , q_group , q_config , narrow_range , hf_range ):
65
+ def dump_fq_params (
66
+ fq_params : FakeQuantizeParameters ,
67
+ q_group : QuantizerGroup ,
68
+ q_config : QuantizerConfig ,
69
+ narrow_range : bool ,
70
+ hf_range : bool ,
71
+ ):
66
72
key = get_test_reference_key (q_group , q_config , narrow_range , hf_range )
67
73
all_fq_params = load_json (FQ_CALCULATED_PARAMETERS_PATH )
68
74
fq_params_dict = parse_fq_params_to_dict (fq_params )
69
75
all_fq_params [key ] = fq_params_dict
70
76
dump_to_json (FQ_CALCULATED_PARAMETERS_PATH , all_fq_params )
71
77
72
78
73
- def parse_fq_params_to_dict (fq_params ):
79
+ def parse_fq_params_to_dict (fq_params : FakeQuantizeParameters ):
74
80
return {
75
81
"levels" : fq_params .levels ,
76
- "input_low" : fq_params .input_low ,
77
- "input_high" : fq_params .input_high ,
78
- "output_low" : fq_params .output_low ,
79
- "output_high" : fq_params .output_high ,
82
+ "input_low" : fq_params .input_low . as_numpy_tensor (). data ,
83
+ "input_high" : fq_params .input_high . as_numpy_tensor (). data ,
84
+ "output_low" : fq_params .output_low . as_numpy_tensor (). data ,
85
+ "output_high" : fq_params .output_high . as_numpy_tensor (). data ,
80
86
}
81
87
82
88
@@ -227,7 +233,8 @@ def test_calculate_quantizer_parameters(self, case_to_test):
227
233
)
228
234
if not case_to_test .should_fail :
229
235
fq_params = calculate_quantizer_parameters (statistics , q_config , quant_group , narrow_range , half_range )
230
- # Uncomment lines below to generate reference for new models.
236
+ # Use OpenVINO backend to collect new reference files.
237
+ # Uncomment lines below to generate reference for new parameters.
231
238
# dump_fq_params(fq_params, quant_group, q_config, narrow_range, half_range)
232
239
ref_fq_params = read_ref_fq_params (quant_group , q_config , narrow_range , half_range )
233
240
compare_fq_parameters (fq_params , ref_fq_params )
0 commit comments