ml_switcheroo.compiler.backends.extras ====================================== .. py:module:: ml_switcheroo.compiler.backends.extras .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: ml_switcheroo.compiler.backends.extras.HtmlBackend ml_switcheroo.compiler.backends.extras.TikzBackend ml_switcheroo.compiler.backends.extras.LatexBackend ml_switcheroo.compiler.backends.extras.MlirBackend ml_switcheroo.compiler.backends.extras.StableHloBackend Module Contents --------------- .. py:class:: HtmlBackend(semantics: Optional[Any] = None) Bases: :py:obj:`ml_switcheroo.compiler.backend.CompilerBackend` Orchestrates the conversion of Logical Graphs to the HTML visual DSL. .. py:attribute:: ROW_HEIGHT :value: 80 .. py:attribute:: GAP_HEIGHT :value: 0 .. py:method:: compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) -> str Compiles the graph into an HTML string document. :param graph: The logical graph. :returns: HTML string. .. py:class:: TikzBackend(semantics: Optional[Any] = None, y_spacing: float = 2.5, x_spacing: float = 3.0) Bases: :py:obj:`ml_switcheroo.compiler.backend.CompilerBackend` Orchestrates the conversion of a LogicalGraph to TikZ source code. Verified to use Rank-Based Layout. .. py:attribute:: y_spacing :value: 2.5 .. py:attribute:: x_spacing :value: 3.0 .. py:method:: compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) -> str Compile graph to TikZ LaTeX code. .. py:class:: LatexBackend(semantics: Optional[Any] = None) Bases: :py:obj:`ml_switcheroo.compiler.backend.CompilerBackend` Transforms Logical Graphs into MIDL LaTeX format. .. py:method:: compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) -> str Compiles graph to LaTeX. .. py:class:: MlirBackend(semantics: Optional[Any] = None) Bases: :py:obj:`ml_switcheroo.compiler.backend.CompilerBackend` Back-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). .. py:attribute:: semantics :value: None .. py:method:: compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) -> str 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"}`. :param graph: The logical graph IR. :returns: The generated MLIR code. :rtype: str .. py:class:: StableHloBackend(semantics: Optional[Any] = None) Bases: :py:obj:`ml_switcheroo.compiler.backend.CompilerBackend` Back-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). .. py:attribute:: semantics :value: None .. py:method:: compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) -> str Compiles the graph to StableHLO-flavored MLIR. :param graph: The logical graph. :returns: MLIR code string using stablehlo dialect. :rtype: str