ml_switcheroo.compiler¶

Compiler Package.

This package defines the core Intermediate Representation (IR) and Backend interfaces for the ml-switcheroo compilation pipeline. It separates the logical definition of a computation graph from the frontend parsing and backend generation logic.

Submodules¶

Classes¶

CompilerBackend

Abstract base class for compilation backends.

LogicalGraph

Language-agnostic representation of the neural network structure.

LogicalNode

Represents a computation unit (Layer) in the graph.

LogicalEdge

Represents data flow between two nodes.

Package Contents¶

class ml_switcheroo.compiler.CompilerBackend[source]¶

Bases: abc.ABC

Abstract base class for compilation backends.

abstractmethod compile(graph: ml_switcheroo.compiler.ir.LogicalGraph) → Any[source]¶

Compiles the Logical Intermediate Representation (IR) into a target artifact.

Parameters:

graph (LogicalGraph) – The intermediate representation of the model structure.

Returns:

The compiled output (e.g., source code string, binary buffer, or AST).

Return type:

Any

class ml_switcheroo.compiler.LogicalGraph[source]¶

Language-agnostic representation of the neural network structure.

name: str = 'Model'¶

Name of the graph model/class.

nodes: List[LogicalNode] = []¶

Ordered list of nodes in the graph.

edges: List[LogicalEdge] = []¶

List of directed edges between nodes.

class ml_switcheroo.compiler.LogicalNode[source]¶

Represents a computation unit (Layer) in the graph.

id: str¶

Unique identifier (e.g. ‘conv1’).

kind: str¶

Operation type (e.g. ‘Conv2d’, ‘Input’, ‘Output’).

metadata: Dict[str, str]¶

Dictionary of configuration parameters (e.g. kernel_size=3).

class ml_switcheroo.compiler.LogicalEdge[source]¶

Represents data flow between two nodes.

source: str¶

Source node ID.

target: str¶

Target node ID.