Can we dump the intermediate files to explore the optimization process when building a model using nnvm.compiler.build()?
You are in luck. There is a mechanism that does exactly what you want.
When building TVM function, enable
dump_ir_pass option, like this:
with tvm.build_config(dump_ir_pass=True): tvm.build(...)
This will dump all intermediate IRs in a current directory.
@masahi Thanks very much
I add the tvm.build_config statement in my code like this:
with nnvm.compiler.build_config(opt_level=2): with tvm.build_config(dump_pass_ir=True): graph, lib, params = nnvm.compiler.build(sym, target, shape_dict, params=params)
and it dump out almost 2000 files, does those files contain the graph level optimization process in NNVM?
Do you have a good learning road map to understand those files?
This flag only dumps passes in tvm, but there are only 40+ passes in tvm, so you may have like 50+ layers in your model you are building. each of them run thru all passes of tvm, so you have 40*50 files.
if you wanna know what’s happening in each pass, you may choose one layer dump files(40+).
Is that still true today, that there are only 40ish passes in TVM and that
dump_pass_ir=True only dumps passes in TVM? I added that flag to TVM’s Relay quick start tutorial, which uses resnet-18 and it outputs around 3600 files, which is way more than 40*18.
Hello, where is this tvm.build_config come from ? I am using tvm 0.8 dev but this does not exist
Hi @huangteng ,
tvm.build_config had been replaced with
PassContext. Check these PRs.
Hi @leeexyz , so what is the equivalent config of dump_ir_pass=True in PassContext? As tvm.build_config have been deprecated?
To debug with IRs, set(USE_RELAY_DEBUG ON) and set environment variable TVM_LOG_DEBUG. export TVM_LOG_DEBUG="ir/transform.cc=1;relay/ir/transform.cc=1"
In short, first, you have to build TVM with debugging support and then set the environment variable before running.