debug_output.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import pickle
  2. df_loc = "output/adaptive/vConv2d.pickle"
  3. with open(df_loc, "rb") as f:
  4. df = pickle.load(f)
  5. debug_outputs = df["debug_outputs"]
  6. message_by_loop = {}
  7. for i, output in enumerate(debug_outputs):
  8. for line in output:
  9. try:
  10. if line.startswith("Start recovery"):
  11. log = (i, "R")
  12. for loop_id in message_by_loop.keys():
  13. message_by_loop[loop_id].append(log)
  14. continue
  15. loop_index_string = "estimation for loop"
  16. loc = line.find(loop_index_string)
  17. assert(loc > -1)
  18. loop_index = loc + len(loop_index_string) + 1
  19. loop_id = line[loop_index:].split()[0]
  20. update_string = "is updated to"
  21. loc = line.find(update_string)
  22. assert(loc > -1)
  23. val_index = loc + len(update_string) + 1
  24. updated_val = line[val_index:].split()[0]
  25. if line.startswith("(recovery)"):
  26. updated_val = "!" + updated_val
  27. if loop_id not in message_by_loop:
  28. message_by_loop[loop_id] = []
  29. log = (i, updated_val)
  30. message_by_loop[loop_id].append(log)
  31. except:
  32. print("incomplete string:", line)
  33. for key in sorted(message_by_loop.keys()):
  34. # print(key, message_by_loop[key])
  35. outputs = []
  36. current_iter = -1
  37. for log in message_by_loop[key]:
  38. i, val = log
  39. while current_iter < i:
  40. current_iter += 1
  41. outputs.append(f"({current_iter})")
  42. outputs.append(val)
  43. print(f"{key}:", " ".join(outputs))