Skip to content

Commit

Permalink
Add summary log
Browse files Browse the repository at this point in the history
  • Loading branch information
RattataKing committed Aug 7, 2024
1 parent 4e45f67 commit 2c2d8d4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tuning/autotune.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,18 @@ def benchmark_unet(
)


def summerize_top_candidates(
path_config: PathConfig, candidate_trackers: list[CandidateTracker]
):
dump_list = []
for candidate in candidate_trackers:
if candidate.unet_benchmark_time is not None:
final_str = f"Candidate {candidate.candidate_id}:\nUnet benchmark time: {candidate.unet_benchmark_time} on device {candidate.unet_benchmark_device_id}\nDispatch benchmark time: {candidate.first_benchmark_time} on device {candidate.unet_benchmark_device_id}\nSpec file: {candidate.mlir_spec_path}\n\n"
dump_list.append(final_str)
with open(path_config.result_summary_log, "w") as file:
file.writelines(dump_list)


def autotune(args: argparse.Namespace) -> None:
path_config = PathConfig()
path_config.base_dir.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -1335,6 +1347,9 @@ def autotune(args: argparse.Namespace) -> None:
if stop_after_phase == ExecutionPhases.benchmark_unet_candidates:
return

summerize_top_candidates(path_config, candidate_trackers)
print(f"Stored top candidates info in {path_config.result_summary_log}\n")

with open(path_config.candidate_trackers_pkl, "wb") as file:
pickle.dump(candidate_trackers, file)
print(f"Candidate trackers are saved in {path_config.candidate_trackers_pkl}\n")
Expand Down

0 comments on commit 2c2d8d4

Please sign in to comment.