Creating this post as a follow-up for discussions that happened in https://github.com/apache/tvm/pull/14186 following from:
In the future it seems good to have more granularity in the IR that is being dumped, e.g. print IR before/after named pass.
The proposal is to add new options to TVMC to print the IR before/after/other-condition a named pass from the build pipeline. Initially this will involve adding two new options:
--print-ir-before=<comma-separated-list-of-pass-names>
--print-ir-after=<comma-separated-list-of-pass-names>
For example, tvmc compile --print-ir-after="PartitionGraph"
could be used to print the IR after the graph has been partitioned in Relay. This can later be extended with other, more advanced, options. This would be a similar approach to the options used in MLIR.
print
is suggested over dump
(used by --dump-code
) as it gives the user more flexibility, and they can always pipe the output to a named file of their choosing.
This seems relatively simple to implement using a pass instrument that can be attached to the current pass context during a tvmc compile
. Using the run_before_pass
and run_after_pass
methods, the module will be printed if the name of the pass is in a user provided set of names.
cc @PhilippvK