Skip to content

Commit bdd1377

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

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Diff for: quantization/nlp/bert/migraphx/e2e_migraphx_bert_example.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,19 @@ 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+
print("Writing calibration.json file without using write_calibration_table")
567+
with open("calibration.json", "w") as f:
568+
json.dump(calibration_table, f)
558569
print("Calibration is done. Calibration cache is saved to calibration.json")
559570

560571
model_quants = model_quants + "_int8"

0 commit comments

Comments
 (0)