ml_switcheroo.core.mlir.generator¶

MLIR to Python (LibCST) Generator.

This module provides the MlirToPythonGenerator class, which consumes the MLIR CST object model and reconstructs valid Python code via LibCST.

Classes¶

MlirToPythonGenerator

Transpiler back-end: MLIR CST -> Python LibCST.

Module Contents¶

class ml_switcheroo.core.mlir.generator.MlirToPythonGenerator[source]¶

Bases: ml_switcheroo.core.mlir.gen_expressions.ExpressionGeneratorMixin, ml_switcheroo.core.mlir.gen_statements.StatementGeneratorMixin, ml_switcheroo.core.mlir.gen_base.BaseGeneratorMixin

Transpiler back-end: MLIR CST -> Python LibCST. Integrates expression and statement generation logic.

ctx¶
usage_counts: Dict[str, int]¶
usage_consumers: Dict[str, ml_switcheroo.core.mlir.nodes.OperationNode]¶
deferred_exprs: Dict[str, libcst.BaseExpression]¶
generate(node: ml_switcheroo.core.mlir.nodes.ModuleNode) → libcst.Module[source]¶

Main entry point. Converts MLIR Module to Python Module.

Parameters:

node – The root MLIR ModuleNode.

Returns:

A LibCST Module object representing the Python code.