Hi, I’m interested in open source projects that represent MLIR as an interactive graph.
I’ve previously created a tool to visualize LLVM IR CFGs ( https://llvmflow.kc-ml2.com/ ), making it easy to compare two graphs before and after optimization, and I was wondering if this could be extended to MLIR.
For LLVM IR, I used debug-information to find the basic blocks that remain unchanged after optimization and LLVM optimizer pass to generate .dot
files and use them to draw interactively on the web.
I found that it is possible to generate .dot
files using ‘ViewOpGraph.cpp’ in MLIR, so I think it is possible.
However, I don’t have much background in MLIR, so I don’t know if it can be represented in a consistent graph regardless of the dialects, and how to know which parts don’t change before and after optimization.
If anyone is interested in working on this project, it would be great to talk and collaborate : )
@jpienaar
And any feedback about LLVM-FLOW ( https://llvmflow.kc-ml2.com/ ) is also welcome !!
5 Likes
Hey! I’d love to have better tools in this area 
There are a few angles:
-
CFG graph: this is what you have in LLVM, multiple blocks are connected in a graph and each block contains a list of operations. This isn’t the most common structure in MLIR though.
-
SSA Graph: the individual operations in a single block are connected through def-use chains to form a graph. It’s often a DAG but not always!
There is a question in the visualization of this about how much the user cares about the order in which the operation are setup (it matters a lot for load/store but not much for side-effect free IR or any “sea of nodes” representation).
These may be options the user want to toggle in the visualizer.
-
Hierarchical regions: most of MLIR control flow uses regions instead of CFG. An ideal visualizer would handle this natively!
If we can cover the 3 points above, we like would have a great tool 
2 Likes
Thanks a lot !! It was a very intuitive and helpful explanation.
About 3 angles:
- The tool will be based on graphviz, so if it is possible to represent the graph in graphviz, it should be possible. Also, the user can move the position of the nodes, so for SSA graphs, I think the user can customize it as they want.
- In the case of region, I think it would be enough to show a group of nodes by drawing a border to form a cluster.
I’ll get a better idea if I try to plot a graph from the dialects myself first (which will probably take a few days).