Visualization of Relay IR #8668
Conversation
leandron
left a comment
There was a problem hiding this comment.
Hi @kueitang, this seems interesting as a way to see Relay.
I think this feature could be integrated with @chiwwang's ongoing work at #8448. Have you seen that PR?
I suggest you two work together to define the correct APIs needed, so that we have one way to implement visualizers for Relay using a common foundation. What do you think?
|
Thanks @leandron! |
b0bfea6 to
fb24fd3
Compare
|
Yes I consider graphs just as nodes and edges. So the Plotter interface is very simple. |
-Add a AST dump pass -It provides a snap shot to the relay IR graph
|
hi @tqchen, |
|
If the high-level design or the interface needs more feedback, it would be better and more efficient to file a formal RFC at the same time. |
Agree with @comaniac. With an RFC, perhaps we could also find alignment to have this and other features e.g. #8448, to be built on top of the same interface, and also other parts consuming this (I can imagine |
|
Hi @kueitang Back to interfaces of Relay visualization, how do you think about a backend-specific render-callback? Specifically, in the constructor of class RelayVisualizer:
"""Relay IR Visualizer"""
def __init__(
self, relay_mod, relay_param=None, plotter_be=PlotterBackend.BOKEH, render_cb=_dft_render_cb
):I try to port this PR with the interface in the following commit in the file The output looks like: I don't know if I should consider multiply/add as an argument of So, currently interfaces of relay-viz in my mind is:
def render_cb(graph, node_to_id, relay_param)
"""
Parameters
----------
graph : class plotter.Graph
node_to_id : Dict[relay.expr, int]
relay_param : Dict[string, NDarray]
"""Additionally, the dict |
* BOKEH BACKEND
* Scalable Text for Node type
* Add arrow-head and TODO
* Use pydot. Remove networkx and pygraphviz dependency
* Add interactive legend and show information based on zoom level
* Support multiple GlobalVar. One global var, one graph
* test reserved post order. try terminal viz by kueitang
…ntegrated two backends * Add a RenderCallback class for reusable nodes type processing
|
|
Hi @areusch, @PhilippvK, @jroesch, @leandron, |
|
Thanks @chiwwang. |
|
|
||
|
|
||
| def get_plotter_and_generator(backend): | ||
| """Specify the Plottor and its NodeEdgeGenerator""" |
There was a problem hiding this comment.
need "Parameters" and "return".
|
|
||
|
|
||
| class VizNode: | ||
| """Node carry information used by `plotter.Graph` interface.""" |
|
|
||
| class VizEdge: | ||
| """Edges for `plotter.Graph` interface.""" | ||
|
|
| def _function_node( | ||
| self, | ||
| node: relay.Expr, | ||
| _: Dict[str, tvm.runtime.NDArray], # relay_param |
|
Thanks @huajsj for reviewing! |
|
Sure, I will figure out how to split this PR to smaller patches. |
This PR follows apache#8668, with splitting out interfaces class and terminal ast-dump implementation. This visualizer is aimed for quick look-then-fix, so the interface is simple. Despite that, customization is still possbile through implementing interfaces defined in `interface.py` or overriding existent implementations inside a renderer module, like `terminal.py`. A tutorial is also provided in this PR. A graphviz renderer will also be contributed after this PR.
|
Closing in favor of #10085 |
* RelayViz interface and terminal ast-dump. This PR follows #8668, with splitting out interfaces class and terminal ast-dump implementation. This visualizer is aimed for quick look-then-fix, so the interface is simple. Despite that, customization is still possbile through implementing interfaces defined in `interface.py` or overriding existent implementations inside a renderer module, like `terminal.py`. A tutorial is also provided in this PR. A graphviz renderer will also be contributed after this PR. * lint and typo
* RelayViz interface and terminal ast-dump. This PR follows apache#8668, with splitting out interfaces class and terminal ast-dump implementation. This visualizer is aimed for quick look-then-fix, so the interface is simple. Despite that, customization is still possbile through implementing interfaces defined in `interface.py` or overriding existent implementations inside a renderer module, like `terminal.py`. A tutorial is also provided in this PR. A graphviz renderer will also be contributed after this PR. * lint and typo
Hi,
This utility is designed for users who are prone to snap-shot the relay IR graph on terminal.
The AST structure format covers basic relay function/expressions such as Function, Call, Let, Var, GlobalVar, If, Tuple, Constant currently.
For example:
A Relay IRModule:
with:
will be showed as:
It is welcome to have your thoughts on the utility.
Anyways, thanks. :)
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.