Add a config to dump IR after each Relay Opt


#1

It looks that it will be convenient for debugging if we can dump out the IR after each opt.

This can be done by either insert relay.transform.PrintIR() after each pass or add a dump_ir=True config into the build_config. But it looks that the later one is more convenient and can be inserted from python.

@jroesch needs this for memory debugging. Should we add it back?


#2

Let us dig deeper into why the later is convenient.

Is it mainly because the default pipeline is constructed in a way that has a lot of boiler-plate? If we have a default pipeline that is constructed from python which can be copy-pasted, will the situation change?

Pushing for a more pragmatic approach to this, it would be interesting to see if we can do some generic call back API like


pipeline = relay.default_build_pipeline()
pipeline = relay.transform.attach_at_each_pass(pipeline, relay.transform.PrintIR())

module = pipeline(input_module)