ml_switcheroo.core.mlir.dialect¶

Switcheroo Dialect Definition (‘sw’).

This module formally defines the MLIR operations for the ‘sw’ high-level dialect. It acts as the schema validation layer for the custom IR, ensuring that transformations produce semantically valid intermediate representations.

Operations: - sw.module: Represents a Class or Scope container. - sw.func: Represents a Function definition. - sw.op: Represents a generic Operation instantiation (e.g. Layers). - sw.call: Represents a function invocation. - sw.getattr: Represents attribute access (v = self.layer). - sw.setattr: Represents attribute assignment (self.layer = v). - sw.constant: Represents literals. - sw.return: Control flow exit. - sw.import: Represents import statements.

Attributes¶

SW_MODULE

SW_FUNC

SW_OP

SW_CALL

SW_GETATTR

SW_SETATTR

SW_CONSTANT

SW_RETURN

SW_IMPORT

Classes¶

OpSchema

Validation schema for a MLIR operation.

DialectRegistry

Central registry for dialect validation.

Module Contents¶

class ml_switcheroo.core.mlir.dialect.OpSchema¶

Validation schema for a MLIR operation.

name: str¶
num_regions: int = 0¶
required_attributes: List[str] = []¶
has_results: bool = False¶
validate(node: ml_switcheroo.core.mlir.nodes.OperationNode) → bool¶

Checks if the CST node conforms to the dialect schema.

ml_switcheroo.core.mlir.dialect.SW_MODULE¶
ml_switcheroo.core.mlir.dialect.SW_FUNC¶
ml_switcheroo.core.mlir.dialect.SW_OP¶
ml_switcheroo.core.mlir.dialect.SW_CALL¶
ml_switcheroo.core.mlir.dialect.SW_GETATTR¶
ml_switcheroo.core.mlir.dialect.SW_SETATTR¶
ml_switcheroo.core.mlir.dialect.SW_CONSTANT¶
ml_switcheroo.core.mlir.dialect.SW_RETURN¶
ml_switcheroo.core.mlir.dialect.SW_IMPORT¶
class ml_switcheroo.core.mlir.dialect.DialectRegistry¶

Central registry for dialect validation.

classmethod validate_op(node: ml_switcheroo.core.mlir.nodes.OperationNode) → bool¶

Validates a single operation node against the schema. Returns False if op is unknown or invalid.

classmethod get_abstract_op(op_name: str) → str¶

Maps a high-level framework op string (e.g. ‘Linear’) to the canonical dialect op. Currently they all map to ‘sw.op’ with type attributes, but this allows future expansion.