Support for graph to mermaid
Similar to https://github.com/pymc-devs/pymc/pull/7826 but for the pytensor graph.
What are the different types of nodes in the graph? Do plates / subgraphs exist (would this be each op)? What is the idea here?
CC: @ricardoV94
Syntax details:
https://mermaid.js.org/syntax/flowchart.html
plates may be useful for Ops with inner graphs (OpFromGraph / Composite / Scan). Otherwise pytensor has two types of nodes: Apply and Variable. Variable(s) -> Apply(Op) -> Variable(s). You may want to distinguish root inputs/outputs visually as well.
You may also want to distinguish visually different variable types (Tensor, Scalar, RNG, Slice, None, ...)
Any preferences on the node shapes?
https://mermaid.js.org/syntax/flowchart.html#node-shapes
Also the different arrow types
Is there a similar function to get nodes, edges? What are the main traversal functions?
Is there a similar function to get nodes, edges? What are the main traversal functions?
You can go from outputs to inputs via x.owner.inputs, the other way around you need to crate a FunctionGraph, and you have a dictionary clients that goes in the other direction. x is a variable, owner is the apply. Root variables have no owner