How to reset Relay to use the default config?

Is there a way to reset Relay to use the default configurations? I want to compare the performance of two tuned logs in one process, but after applying autotvm.apply_history_best() for the first log, it also affect the second run. Is there a way to revert the effect of apply_history_best()? Thank you!

This is a tricky question. Theoretically you only need to build the module again without apply_history_best and measure its latency. However, if you build the same module twice, the compiler engine will use the previous built programs to reduce the build time. This can be resolved by adding the following lines:

from tvm.relay.backend import compile_engine
...
compile_engine.get().clear()
with apply_history_best(...):
  graph, lib, params = relay.build_module.build(mod, target=target, params=params)
runtime1 = graph_runtime.create(graph, lib, dev_ctx)

compile_engine.get().clear()
graph, lib, params = relay.build_module.build(mod, target=target, params=params)
runtime2 = graph_runtime.create(graph, lib, dev_ctx)

The whole idea is to clean the cache in compiler engine and make sure it builds the module from scratch.

1 Like

@comaniac Your solution works great! Thanks for the explanation.