// print the equivalent python schedule API, and build the binary again.
// Load the measuremnt record for the best schedule
inp, res = auto_scheduler.load_best(log_file, task.workload_key)
// Print equivalent python schedule API. This can be used for debugging and
// learning the behavior of the auto-scheduler.
print("Equivalent python schedule:")
print(task.compute_dag.print_python_code_from_state(inp.state))
// Rebuild the binary. This shows how you can apply the best schedule from a
// log file without reruning the search again.
sch, args = task.compute_dag.apply_steps_from_state(inp.state)
func = tvm.build(sch, args, target)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// A more complicated example is to resume the search.
// In this case, we need to create the search policy and cost model by ourselves
// and resume the status of search policy and cost model with the log file.
// In the example below we resume the status and do more 5 trials.
cost_model = auto_scheduler.XGBModel()
cost_model.update_from_file(log_file)
search_policy = auto_scheduler.SketchPolicy(
task, cost_model, init_search_callbacks=[auto_scheduler.PreloadMeasuredStates(log_file)]
)
measure_ctx = auto_scheduler.LocalRPCMeasureContext(min_repeat_ms=300)
tune_option = auto_scheduler.TuningOptions(
num_measure_trials=5,
runner=measure_ctx.runner,
measure_callbacks=[auto_scheduler.RecordToFile(log_file)],
)
sch, args = auto_scheduler.auto_schedule(task, search_policy, tuning_options=tune_option)
// Kill the measurement process
del measure_ctx
After Change
print(task.print_best(log_file, print_mode="schedule"))
print("CUDA source code:")
print(task.print_best(log_file, print_mode="cuda"))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// A more complicated example is to resume the search.
// In this case, we need to create the search policy and cost model by ourselves