GraphExporter

scalation.modeling.autograd.GraphExporter
object 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 Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

case class Edge(src: String, dst: String, kind: String)

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 Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class FuncNode(id: String, op: String, attrs: Map[String, String], shape: List[Int], depth: Int)

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 Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class GraphModel(vars: Seq[VarNode], funcs: Seq[FuncNode], edges: Seq[Edge], root: String)

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 Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class RenderOptions(showAnnotations: Boolean = ..., edgeShapes: Boolean = ..., nodeShapes: Boolean = ..., colorScheme: String = ..., groupBy: String = ..., showLegend: Boolean = ...)

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 Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class VarNode(id: String, isParam: Boolean, isOutput: Boolean, shape: List[Int], name: Option[String], grad: Option[TensorD])

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 Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def build(root: Variabl, includeGrad: Boolean = ...): GraphModel

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 GraphModel for visualization

def makeDot(root: Variabl, path: String, render: Boolean = ...): Try[String]

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

def toDot(g: GraphModel, opts: RenderOptions = ...): String

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

def toDot(g: GraphModel, showGrad: Boolean): String

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

def toJson(g: GraphModel): String

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

def toMermaid(g: GraphModel): String

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

def writeAll(root: Variabl, dir: String, baseName: String, opts: RenderOptions = ..., svg: Boolean = ..., mermaid: Boolean = ..., json: Boolean = ...): Try[Seq[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

def writeDot(root: Variabl, path: String, opts: RenderOptions = ..., renderSvg: Boolean = ...): Try[String]

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