How to dump Relay IR when compiling model

Is there a way to dump the Relay IR when building a model, in addition to the TVM IR?

This is related to https://discuss.tvm.ai/t/how-to-dump-irs-for-each-pass-when-building-a-model/454, but the solution given (repeated below) only dumps the TVM IR:

  with tvm.build_config(dump_ir_pass=True):
      tvm.build(...)

Is it possible to also dump any intermediate files from the graph optimization process in Relay?

We have been transitioning all of the passes over to some new pass manager infrastructure in the past few weeks, we don’t have an easily exposed flag for this right now, but is something we were planning to expose now that we have moved over.

I will try to expose an easy way to do this for you.

We are currently working to bring the tvm::Expr machinery over to the new things we built for Relay, but that will be a longer term process, hopefully sometime this year we will have a unified way to dump all the IR.

@zhiics and I discussed a bit and he has implemented an initial version of the feature, it should be upstreamed in the next few days.

See: https://github.com/dmlc/tvm/pull/3493

I’ll keep a lookout for it, thanks!