ml_switcheroo.compiler.registry¶

Compiler Registry.

Centralizes registration of Frontends (Source -> IR) and Backends (IR -> Target) for the compiler pipeline.

This registry maps framework keys to their respective compiler components. It cleanly separates Low-Level ISAs (SASS, RDNA) which use the explicit Graph/Compiler pipeline, from High-Level frameworks (Torch, JAX, MLIR, TikZ) which flow through the CST Rewriter pipeline.

Classes¶

BaseFrontend

Abstract base for registry typing.

GraphFrontend

Produces LogicalGraph from code via parse/lift chain.

Functions¶

get_backend_class(...)

Returns the backend class for the target (e.g. 'sass').

is_isa_target(→ bool)

Determines if the target requires the Graph Compiler pipeline.

is_isa_source(→ bool)

Determines if the source requires Lifting (ASM -> Graph -> AST).

Module Contents¶

class ml_switcheroo.compiler.registry.BaseFrontend[source]¶

Abstract base for registry typing.

class ml_switcheroo.compiler.registry.GraphFrontend[source]¶

Bases: BaseFrontend

Produces LogicalGraph from code via parse/lift chain.

parse_to_graph(code: str) → Any[source]¶
ml_switcheroo.compiler.registry.get_backend_class(target: str) → Type[ml_switcheroo.compiler.backend.CompilerBackend] | None[source]¶

Returns the backend class for the target (e.g. ‘sass’).

Parameters:

target – The target framework identifier.

Returns:

The backend class type or PythonBackend if not found, or None.

ml_switcheroo.compiler.registry.is_isa_target(target: str) → bool[source]¶

Determines if the target requires the Graph Compiler pipeline.

Only Low-Level Assembly targets handling Registers or Visualization backends that strictly consume Graphs are routed here.

Note: MLIR/StableHLO/TikZ/Latex/HTML/RDNA/SASS use this path for graph-based generation if selected as target in CLI, bypassing the CST rewriter.

Parameters:

target – The target framework identifier.

Returns:

True if the target is an ISA or Graph-based format.

ml_switcheroo.compiler.registry.is_isa_source(source: str) → bool[source]¶

Determines if the source requires Lifting (ASM -> Graph -> AST). Only SASS and RDNA are treated as low-level source inputs.

Parameters:

source – The source framework identifier.

Returns:

True if the source is an ISA requiring lifting.