ml_switcheroo.compiler.backends.extras¶
Extra Backends (Standardized implementations for Visual/DSL Targets).
Provides CompilerBackend implementations for: - TikZ (Visualization) - HTML (Visualization) - LaTeX DSL (MIDL) - MLIR (Graph to MLIR Text) - StableHLO (Graph to StableHLO-flavored MLIR Text)
These backends consume the LogicalGraph IR and emit target-specific textual representations.
Classes¶
Orchestrates the conversion of Logical Graphs to the HTML visual DSL. |
|
Orchestrates the conversion of a LogicalGraph to TikZ source code. |
|
Transforms Logical Graphs into MIDL LaTeX format. |
|
Back-end for generating MLIR text from a LogicalGraph. |
|
Back-end for generating StableHLO text from a LogicalGraph. |
Module Contents¶
- class ml_switcheroo.compiler.backends.extras.HtmlBackend(semantics: Any | None = None)[source]¶
Bases:
ml_switcheroo.compiler.backend.CompilerBackendOrchestrates the conversion of Logical Graphs to the HTML visual DSL.
- ROW_HEIGHT = 80¶
- GAP_HEIGHT = 0¶
- compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) str[source]¶
Compiles the graph into an HTML string document.
- Parameters:
graph – The logical graph.
- Returns:
HTML string.
- class ml_switcheroo.compiler.backends.extras.TikzBackend(semantics: Any | None = None, y_spacing: float = 2.5, x_spacing: float = 3.0)[source]¶
Bases:
ml_switcheroo.compiler.backend.CompilerBackendOrchestrates the conversion of a LogicalGraph to TikZ source code. Verified to use Rank-Based Layout.
- y_spacing = 2.5¶
- x_spacing = 3.0¶
- compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) str[source]¶
Compile graph to TikZ LaTeX code.
- class ml_switcheroo.compiler.backends.extras.LatexBackend(semantics: Any | None = None)[source]¶
Bases:
ml_switcheroo.compiler.backend.CompilerBackendTransforms Logical Graphs into MIDL LaTeX format.
- compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) str[source]¶
Compiles graph to LaTeX.
- class ml_switcheroo.compiler.backends.extras.MlirBackend(semantics: Any | None = None)[source]¶
Bases:
ml_switcheroo.compiler.backend.CompilerBackendBack-end for generating MLIR text from a LogicalGraph.
This implementation provides a direct Graph-to-MLIR conversion path for scenarios bypassing the high-level Python CST Rewriter (e.g. source is RDNA).
- semantics = None¶
- compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) str[source]¶
Compiles the LogicalGraph into an MLIR string representation.
It emits a simple module structure with a single block, mapping each logical node to an sw.op operation. Inputs are generated as sw.constant if metadata values exist, or sw.op {type=”Input”}.
- Parameters:
graph – The logical graph IR.
- Returns:
The generated MLIR code.
- Return type:
str
- class ml_switcheroo.compiler.backends.extras.StableHloBackend(semantics: Any | None = None)[source]¶
Bases:
ml_switcheroo.compiler.backend.CompilerBackendBack-end for generating StableHLO text from a LogicalGraph.
This implementation provides a direct Graph-to-StableHLO conversion path used when an ISA is the source format (e.g. SASS -> StableHLO).
- semantics = None¶
- compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) str[source]¶
Compiles the graph to StableHLO-flavored MLIR.
- Parameters:
graph – The logical graph.
- Returns:
MLIR code string using stablehlo dialect.
- Return type:
str