ml_switcheroo.testing.fuzzer

Input Generation Engine for Semantics Verification.

This module provides the InputFuzzer, responsible for creating randomized NumPy arrays, scalars, and complex container structures to feed into Framework A and Framework B during behavioral verification tests.

Updates:
  • Support for dtype constraints in array generation (Limitation #2 Fix).

Classes

InputFuzzer

Generates dummy inputs (Arrays, Scalars, Containers) for equivalence testing.

Module Contents

class ml_switcheroo.testing.fuzzer.InputFuzzer(seed_shape: Tuple[int, Ellipsis] | None = None)

Generates dummy inputs (Arrays, Scalars, Containers) for equivalence testing.

MAX_RECURSION_DEPTH = 3
max_depth = 3
generate_inputs(params: List[str], hints: Dict[str, str] | None = None, constraints: Dict[str, Dict] | None = None) Dict[str, Any]

Creates a dictionary of {arg_name: value}.

Resolves symbolic dimensions across the entire parameter set. For example, if hints are {‘x’: “Array[‘N’]”, ‘y’: “Array[‘N’]”}, both arrays will have matching lengths.

Parameters:
  • params – List of argument names to generate (e.g. [‘x’, ‘axis’]).

  • hints – Dictionary of {arg_name: type_string} derived from Spec.

  • constraints – Dictionary of {arg_name: {min, max, options, dtype}}.

Returns:

Randomized inputs ready for Framework adaptation.

Return type:

Dict[str, Any]

adapt_to_framework(kwargs: Dict[str, Any], framework: str) Dict[str, Any]

Converts Numpy inputs to framework-specific tensor types.

Delegates to registered adapters (e.g., TorchAdapter, JaxAdapter).

Parameters:
  • kwargs – Input dictionary with Numpy values.

  • framework – Key of the framework (e.g., “torch”, “jax”).

Returns:

Dict with framework-specific tensors.