chiwwang commented on pull request #8668:
URL: https://github.com/apache/tvm/pull/8668#issuecomment-903155532


   Hi @kueitang
   Maybe we can re-use this RFC, 
https://discuss.tvm.apache.org/t/rfc-visualizing-relay-program-as-graph/4825
   There are some valuable thoughts there :)
   
   Back to interfaces of Relay visualization, how do you think about a 
backend-specific render-callback? Specifically, in the constructor of 
`RelayVisualizer` in #8448 :
   ```python
   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 
`_terminal.py`.
   
https://github.com/chiwwang/tvm/commit/4d1e14a1fa0fdef09ac3c8a7f0556588a276e5f1
   (I also make the callback coupled with the backend....but this seems not a 
good idea. A common render-callback can save efforts of implementing a new 
backend.)
   
   The output looks like:
   ```
   `@main([Var(x)])
     `--Call multiply
       |--Var(Input)
       `--Call add
         |--Var(Input)
         `--Constshape: (), dtype: int32`
   ```
   I don't know if I should consider multiply/add as an argument of `Call`, so 
I put it in `Call` string.
   This might be fixed by modifying tmv.ir.Op branch in the callback.
   
   So, currently interfaces of relay-viz in my mind is:
   1. class Plotter and class Graph in plotter.py (one plotter can have lots of 
graphs)
   2. If needed, a backend-specific render-callback can overwrite the default 
one, with the prototype
   ```python
   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 `node_to_id` ensure its order of keys is in the 
post-order of a relay `GlobalVar`.
   How do you think this kind of integration?
   Thanks :)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to