GraphExporter
GraphExporter generates a computation graph visualization from a root Variabl. The graph includes variables, functions, dependency edges, tensor shapes, and optional gradient annotations. The resulting graph can be serialized to DOT, Mermaid, or JSON formats for visualization.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
GraphExporter.type
Members list
Type members
Classlikes
A directed graph edge.
A directed graph edge.
Value parameters
- dst
-
destination node identifier
- kind
-
edge type (currently only "data")
- src
-
source node identifier
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A function node (operation) in the computation graph.
A function node (operation) in the computation graph.
Value parameters
- attrs
-
operator-specific attributes
- depth
-
depth level for layered graph layout
- id
-
unique identifier for the function
- op
-
operation name (e.g., "add", "matmul")
- shape
-
tensor shape of the function output
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Internal model of the full computation graph.
Internal model of the full computation graph.
Value parameters
- edges
-
all dependency edges
- funcs
-
all function nodes
- root
-
id of the root output variable
- vars
-
all variable nodes
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Rendering options for DOT output.
Rendering options for DOT output.
Value parameters
- colorScheme
-
color theme for rendering (reserved for future use)
- edgeShapes
-
whether to label edges with tensor shapes
- groupBy
-
grouping mode ("depth" or "none")
- nodeShapes
-
whether to display tensor shapes inside nodes
- showAnnotations
-
whether to annotate nodes that have stored gradients
- showLegend
-
whether to include a legend cluster in the DOT output
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A variable node in the exported computation graph.
A variable node in the exported computation graph.
Value parameters
- grad
-
optional stored gradient tensor
- id
-
unique identifier for the variable
- isOutput
-
whether this variable is the graph’s final output
- isParam
-
whether this variable represents a trainable parameter
- name
-
optional user-defined name
- shape
-
tensor shape of the variable
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Build a computation graph starting from a root Variabl. Traverses all dependent variables, topologically sorts functions, assigns depth levels, and constructs variable/function nodes and edges.
Build a computation graph starting from a root Variabl. Traverses all dependent variables, topologically sorts functions, assigns depth levels, and constructs variable/function nodes and edges.
Value parameters
- includeGrad
-
whether to attach stored gradients to variable nodes
- root
-
the root output variable
Attributes
- Returns
-
a structured
GraphModelfor visualization
Backward-compatible alias for writeDot.
Backward-compatible alias for writeDot.
Value parameters
- path
-
target DOT file
- render
-
whether to also produce SVG
- root
-
root variable
Attributes
Convert a graph model into GraphViz DOT format. Supports optional depth-based clustering, shape labels, gradient tags, and legend rendering.
Convert a graph model into GraphViz DOT format. Supports optional depth-based clustering, shape labels, gradient tags, and legend rendering.
Value parameters
- g
-
the computation graph
- opts
-
rendering options
Attributes
- Returns
-
DOT string representation
Backward-compatible DOT exporter using only a gradient toggle.
Backward-compatible DOT exporter using only a gradient toggle.
Value parameters
- g
-
the computation graph
- showGrad
-
whether to annotate gradient availability
Attributes
Export the graph in JSON format for D3.js visualizations.
Export the graph in JSON format for D3.js visualizations.
Value parameters
- g
-
the graph model
Attributes
- Returns
-
JSON string containing nodes and edges
Export the computation graph in Mermaid Flowchart syntax. Variables become rounded nodes; functions become double-curly nodes.
Export the computation graph in Mermaid Flowchart syntax. Variables become rounded nodes; functions become double-curly nodes.
Value parameters
- g
-
the graph model
Attributes
- Returns
-
Mermaid flowchart string
Write all supported graph formats (DOT, SVG, Mermaid, JSON) into a directory.
Write all supported graph formats (DOT, SVG, Mermaid, JSON) into a directory.
Value parameters
- baseName
-
base filename without extension
- dir
-
output directory
- json
-
whether to export JSON
- mermaid
-
whether to export Mermaid
- opts
-
rendering options
- root
-
root variable
- svg
-
whether to export SVG
Attributes
- Returns
-
sequence of file paths written
Write DOT output to a file, with optional GraphViz SVG rendering.
Write DOT output to a file, with optional GraphViz SVG rendering.
Value parameters
- opts
-
rendering options
- path
-
target .dot file path
- renderSvg
-
whether to also generate an SVG via
dot -Tsvg - root
-
root variable of the computation graph
Attributes
- Returns
-
path of written file or SVG file