loader.cpp: support dumping IR/Graph visualizations from the commandline#148
loader.cpp: support dumping IR/Graph visualizations from the commandline#148aweis merged 2 commits intopytorch:masterfrom aweis:export
Conversation
This commit adds the following flags: -dumpGraph - Prints Graph to stdout -dumpGraphDAG=<file.dot> - Specify the file to export the Graph in DOT format -dumpIR - Prints IR to stdout -dumpIRDAG=<file.dot> - Specify the file to export the IR in DOT format I had to slightly change the Module::dumpDAG() function to take in an optional filepath. This is consistent with how the dumpDAG() function works in Graph.cc.
|
These changes are looking good! I like that you've made the interface for the graph and the IR the same. This is good. I have a small request. Can you please add an overload to the function that accepts no parameter instead of a default argument? The reason is that when you call the function in the debugger (p G_->dumpDAG()) it gives and error, because LLDB does not fill in default arguments. Overloading the function would allow us to call the function from the debugger. |
Nadav suggested that we make our IR/DAG representations easier to debug when using a debugger. When you call the function in the debugger (p G_->dumpDAG()) it would give an error before this change.
|
@nadavrot ^ I added the commit above with your suggestion. LMK if this is what you wanted and I will merge. |
|
Looks nice! My only concern is: these flags can be useful not only inside the loader, but as general purpose flags to be used with Glow-based tools, e.g. if you debug tests, etc. Thus having the definitions of these command-line options inside loader.cpp is may be not such a great idea. May be they should be in IR.cpp and Graph.cpp respectively? IMHO, the loader should just use these flags, but not define them. |
|
@opti-mix Roman, how will we know when to dump the DAG? In the loader we have a clear answer. In general code you never know if you want to dump before the auto-grad or after. Before optimizations or after. Before the target-specific-lowering or after, etc. I think that this is a good start. |
This commit adds the following flags:
-dumpGraph - Prints Graph to stdout
-dumpGraphDAG=<file.dot> - Specify the file to export the Graph in DOT format
-dumpIR - Prints IR to stdout
-dumpIRDAG=<file.dot> - Specify the file to export the IR in DOT format
I had to slightly change the Module::dumpDAG() function to take in an
optional filepath. This is consistent with how the dumpDAG() function works
in Graph.cc.