ml_switcheroo.frameworks.base¶

Base Protocol and Registry for Framework Adapters.

This module defines the interface that all Framework Adapters must implement. Updated to remove legacy create_parser and create_emitter hooks, enforcing the new Pipeline Routing architecture.

Attributes¶

SNAPSHOT_DIR

Classes¶

StandardCategory

Enumeration of API categories for discovery.

InitMode

Initialization mode for adapters.

ImportConfig

Configuration for an exposed namespace.

StandardMap

Defines how a Framework implements a Middle Layer standard.

FrameworkAdapter

Protocol definition for a Framework Adapter.

Functions¶

load_snapshot_for_adapter(→ Dict[str, Any])

register_framework(name)

available_frameworks(→ List[str])

get_adapter(→ Optional[FrameworkAdapter])

Module Contents¶

ml_switcheroo.frameworks.base.SNAPSHOT_DIR¶
class ml_switcheroo.frameworks.base.StandardCategory[source]¶

Bases: str, enum.Enum

Enumeration of API categories for discovery.

LOSS = 'loss'¶
OPTIMIZER = 'optimizer'¶
LAYER = 'layer'¶
ACTIVATION = 'activation'¶
class ml_switcheroo.frameworks.base.InitMode[source]¶

Bases: str, enum.Enum

Initialization mode for adapters.

LIVE = 'live'¶
GHOST = 'ghost'¶
class ml_switcheroo.frameworks.base.ImportConfig(/, **data: Any)[source]¶

Bases: pydantic.BaseModel

Configuration for an exposed namespace.

tier: ml_switcheroo.enums.SemanticTier = None¶
recommended_alias: str | None = None¶
class ml_switcheroo.frameworks.base.StandardMap(/, **data: Any)[source]¶

Bases: pydantic.BaseModel

Defines how a Framework implements a Middle Layer standard.

api: str | None = None¶
args: Dict[str, str | None] | None = None¶
inject_args: Dict[str, Any] | None = None¶
requires_plugin: str | None = None¶
transformation_type: str | None = None¶
operator: str | None = None¶
pack_to_tuple: str | None = None¶
macro_template: str | None = None¶
output_cast: str | None = None¶
arg_values: Dict[str, Dict[str, str]] | None = None¶
required_imports: List[str | Any] = None¶
missing_message: str | None = None¶
layout_map: Dict[str, str] | None = None¶
class ml_switcheroo.frameworks.base.FrameworkAdapter[source]¶

Bases: Protocol

Protocol definition for a Framework Adapter.

convert(data: Any) → Any[source]¶
property test_config: Dict[str, str]¶
property harness_imports: List[str]¶
get_harness_init_code() → str[source]¶
get_to_numpy_code() → str[source]¶
property search_modules: List[str]¶
property display_name: str¶
property ui_priority: int¶
property discovery_heuristics: Dict[str, List[str]]¶
property supported_tiers: List[ml_switcheroo.enums.SemanticTier]¶
property import_alias: Tuple[str, str]¶
property inherits_from: str | None¶
property structural_traits: ml_switcheroo.semantics.schema.StructuralTraits¶
property plugin_traits: ml_switcheroo.semantics.schema.PluginTraits¶
property rng_seed_methods: List[str]¶
property declared_magic_args: List[str]¶
property unsafe_submodules: Set[str]¶
get_device_syntax(device_type: str, device_index: str | None = None) → str[source]¶
get_device_check_syntax() → str[source]¶
get_rng_split_syntax(rng_var: str, key_var: str) → str[source]¶
get_serialization_syntax(op: str, file_arg: str, object_arg: str | None = None) → str[source]¶
get_serialization_imports() → List[str][source]¶
get_weight_conversion_imports() → List[str][source]¶
get_weight_load_code(path_var: str) → str[source]¶
get_tensor_to_numpy_expr(tensor_var: str) → str[source]¶
get_weight_save_code(state_var: str, path_var: str) → str[source]¶
get_doc_url(api_name: str) → str | None[source]¶
get_tiered_examples() → Dict[str, str][source]¶
property definitions: Dict[str, StandardMap]¶
property specifications: Dict[str, ml_switcheroo.semantics.schema.OperationDef]¶
property import_namespaces: Dict[str, Dict[str, str] | ImportConfig]¶
collect_api(category: StandardCategory) → List[ml_switcheroo.core.ghost.GhostRef][source]¶
apply_wiring(snapshot: Dict[str, Any]) → None[source]¶
ml_switcheroo.frameworks.base.load_snapshot_for_adapter(fw_key: str) → Dict[str, Any][source]¶
ml_switcheroo.frameworks.base.register_framework(name: str)[source]¶
ml_switcheroo.frameworks.base.available_frameworks() → List[str][source]¶
ml_switcheroo.frameworks.base.get_adapter(name: str) → FrameworkAdapter | None[source]¶