ml_switcheroo.testing.runner ============================ .. py:module:: ml_switcheroo.testing.runner .. autoapi-nested-parse:: Execution Engine for Semantics Verification. This module provides the `EquivalenceRunner`, which executes operations across multiple frameworks (PyTorch, JAX, etc.) to verify behavioral equivalence. It handles input generation, type adaptation, and crucially, **argument mapping** to ensure that standard inputs are passed to frameworks using their specific parameter names (e.g., mapping `axis` to `dim`). Updates: - Added support for `shape_calc` lambda verification (Feature 20). - Uses central registry for output normalization. Classes ------- .. autoapisummary:: ml_switcheroo.testing.runner.EquivalenceRunner Module Contents --------------- .. py:class:: EquivalenceRunner Executes and compares operations across different Deep Learning frameworks. .. attribute:: fuzzer The engine used to generate randomized inputs. :type: InputFuzzer .. py:attribute:: fuzzer .. py:method:: verify(variants: Dict[str, Any], params: List[str], hints: Optional[Dict[str, str]] = None, constraints: Optional[Dict[str, Dict]] = None, shape_calc: Optional[str] = None) -> Tuple[bool, str] Runs the operation across all defined variants and compares results. This process includes: 1. Fuzzing: Generates standard NumPy inputs based on `params`, `hints` and `constraints`. 2. Renaming: Maps standard argument names to framework-specific names defined in the Semantics (e.g., `axis` -> `dim`). 3. Adaptation: Converts NumPy arrays to framework Tensors. 4. Execution: Runs the functions via dynamic import. 5. Normalization: Converts results back to NumPy. 6. **Shape Check**: Verifies result shape using `shape_calc` lambda if provided. 7. Comparison: Asserts numeric closeness between frameworks. :param variants: Dictionary of framework implementations from the Semantic Knowledge Base. :param params: List of standard argument names (e.g. `['x', 'axis']`). :param hints: Dictionary of type hints (e.g. `{'axis': 'int'}`) to guide the fuzzer. Uses explicit types over heuristics. :param constraints: Dictionary of constraint maps (min, max, options) to bound fuzzer. :param shape_calc: Optional python lambda string (e.g. `lambda x: x.shape`) to verify output shape. :returns: A pair containing: - bool: True if the verification passed (or skipped). - str: A human-readable status message or error log. :rtype: Tuple[bool, str]