pixano_inference.frameworks.base
Framework adapter protocol and registry.
pixano-inference is framework-agnostic: the core depends on numpy only, and each ML framework (PyTorch, JAX, TensorFlow, MLX) is an optional extra reached through an adapter. An adapter gives a model author framework-neutral helpers — device resolution, dtype resolution, and numpy interchange — so a custom model can be written against any supported framework without the core privileging one of them.
numpy is the interchange format: adapters convert their native arrays/tensors to and from
numpy.ndarray (zero-copy via DLPack where the framework supports it).
This module imports NO framework at load time. Adapter modules (torch, jax, …) are
imported lazily by :func:get_adapter, and each performs its own framework import lazily,
so import pixano_inference.frameworks stays dependency-free.
FrameworkAdapter
Bases: Protocol
Framework-neutral operations a model backend needs.
Implementations live in pixano_inference.frameworks.<name> and import their
framework lazily.
from_numpy(array, device=None, dtype=None)
Convert a numpy array to a framework array/tensor on device with dtype.
is_available()
resolve_device(num_gpus)
resolve_dtype(dtype)
available_frameworks()
Return the names of frameworks whose package is importable in this environment.
Source code in pixano_inference/frameworks/base.py
get_adapter(name)
Return the adapter for framework name, importing its module lazily.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Framework name ( |
required |
Returns:
| Type | Description |
|---|---|
The registered
|
class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If name is not a known framework. |
Source code in pixano_inference/frameworks/base.py
register_adapter(adapter)
Register a framework adapter instance (called by adapter modules on import).