ml_switcheroo.frameworks.mlx ============================ .. py:module:: ml_switcheroo.frameworks.mlx .. autoapi-nested-parse:: Apple MLX Framework Adapter. This module provides the adapter for Apple's MLX array framework. It supports: 1. **Unified Memory math**: Mapping `mlx.core` operations. 2. **Neural Networks**: Mapping `mlx.nn` layers and containers. 3. **Discovery**: Runtime introspection of the MLX API surface. 4. **Test Config**: Provides generation templates for `gen-tests`. Refactor: Distributed definitions populated for MLX specific Layers, Ops, and Optimizers. Classes ------- .. autoapisummary:: ml_switcheroo.frameworks.mlx.MLXAdapter Module Contents --------------- .. py:class:: MLXAdapter Adapter for Apple MLX (Silicon-optimized tensor framework). .. py:attribute:: display_name :type: str :value: 'Apple MLX' .. py:attribute:: inherits_from :type: Optional[str] :value: None .. py:attribute:: ui_priority :type: int :value: 50 .. py:property:: search_modules :type: List[str] Returns list of MLX submodules to scan during discovery. .. py:property:: import_alias :type: Tuple[str, str] `import mlx.core as mx`. :type: Default alias for core array operations .. py:property:: import_namespaces :type: Dict[str, Dict[str, str]] Defines namespace mapping for source-to-target imports. Maps `torch.nn` -> `mlx.nn` (aliased as `nn`) and `mlx.core` mappings. .. py:property:: discovery_heuristics :type: Dict[str, List[str]] Regex patterns for categorizing discovered APIs into Tiers. .. py:property:: test_config :type: Dict[str, str] Templates for generating physical verification tests. .. py:property:: supported_tiers :type: List[ml_switcheroo.enums.SemanticTier] Returns supported semantic tiers (Array, Neural, Extras). .. py:property:: structural_traits :type: ml_switcheroo.frameworks.base.StructuralTraits Defines structural rewriting rules (Classes, Methods, Init). .. py:property:: definitions :type: Dict[str, ml_switcheroo.frameworks.base.StandardMap] Static definitions for MLX mappings. Covers Optimization, Math, Layers, and Compilation. .. py:property:: rng_seed_methods :type: List[str] Returns list of global seed setters. .. py:method:: collect_api(category: ml_switcheroo.frameworks.base.StandardCategory) -> List[ml_switcheroo.core.ghost.GhostRef] Performs runtime introspection to discover available MLX APIs. .. py:method:: convert(data: Any) -> Any Converts input data (NumPy/List) to MLX Tensor for verification. .. py:method:: get_example_code() -> str :classmethod: Returns default example. .. py:method:: get_tiered_examples() -> Dict[str, str] Returns MLX idiomatic examples used for validity testing. .. py:method:: get_device_syntax(device_type: str, device_index: Optional[str] = None) -> str Returns device constructor syntax. .. py:method:: get_serialization_imports() -> List[str] Returns imports for serialization. .. py:method:: get_serialization_syntax(op: str, file_arg: str, object_arg: Optional[str] = None) -> str Returns save/load syntax. .. py:method:: apply_wiring(snapshot: Dict[str, Any]) -> None Applies manual wiring for MLX. Overrides/Patches snapshot items that cannot be statically defined.