Skip to content

Commit 1b1f672

Browse files
committed
Fix 'tuple' object has no attribute 'to_dict' for bert
1 parent afba506 commit 1b1f672

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

quantization/nlp/bert/migraphx/e2e_migraphx_bert_example.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,18 @@ def output_run_config(flags, samples):
553553
for k, v in compute_range.data.items():
554554
json_compute_range[k] = (float(v.range_value[0]), float(v.range_value[1]))
555555

556-
557-
write_calibration_table(json_compute_range)
556+
print("Writing calibration table")
557+
try:
558+
write_calibration_table(json_compute_range)
559+
except AttributeError as e:
560+
calibration_table = {}
561+
for k, v in compute_range.data.items():
562+
min_val = float(v.range_value[0]) if hasattr(v.range_value[0], 'item') else float(v.range_value[0])
563+
max_val = float(v.range_value[1]) if hasattr(v.range_value[1], 'item') else float(v.range_value[1])
564+
calibration_table[k] = [min_val, max_val]
565+
566+
with open("calibration.flatbuffers", "w") as f:
567+
json.dump(calibration_table, f)
558568
print("Calibration is done. Calibration cache is saved to calibration.json")
559569

560570
model_quants = model_quants + "_int8"

0 commit comments

Comments
 (0)