ameva-runtime 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ameva_runtime/__init__.py +64 -0
- ameva_runtime/adapters/__init__.py +23 -0
- ameva_runtime/adapters/base.py +67 -0
- ameva_runtime/adapters/bitnet.py +50 -0
- ameva_runtime/adapters/diffusion.py +50 -0
- ameva_runtime/adapters/llamacpp.py +88 -0
- ameva_runtime/adapters/stt.py +50 -0
- ameva_runtime/adapters/tts.py +50 -0
- ameva_runtime/adapters/vision.py +51 -0
- ameva_runtime/cli.py +302 -0
- ameva_runtime/core.py +305 -0
- ameva_runtime/detector.py +232 -0
- ameva_runtime/doctor.py +194 -0
- ameva_runtime/exceptions.py +90 -0
- ameva_runtime/platform.py +87 -0
- ameva_runtime/protocol.py +118 -0
- ameva_runtime/router.py +123 -0
- ameva_runtime-1.0.0.dist-info/METADATA +123 -0
- ameva_runtime-1.0.0.dist-info/RECORD +40 -0
- ameva_runtime-1.0.0.dist-info/WHEEL +5 -0
- ameva_runtime-1.0.0.dist-info/entry_points.txt +4 -0
- ameva_runtime-1.0.0.dist-info/licenses/LICENSE +17 -0
- ameva_runtime-1.0.0.dist-info/top_level.txt +2 -0
- ameva_vulkan_runtime/__init__.py +64 -0
- ameva_vulkan_runtime/adapters/__init__.py +34 -0
- ameva_vulkan_runtime/adapters/base.py +170 -0
- ameva_vulkan_runtime/adapters/bitnet.py +105 -0
- ameva_vulkan_runtime/adapters/diffusion.py +144 -0
- ameva_vulkan_runtime/adapters/llamacpp.py +267 -0
- ameva_vulkan_runtime/adapters/stt.py +109 -0
- ameva_vulkan_runtime/adapters/tts.py +72 -0
- ameva_vulkan_runtime/adapters/vision.py +165 -0
- ameva_vulkan_runtime/bindings.py +123 -0
- ameva_vulkan_runtime/cli.py +132 -0
- ameva_vulkan_runtime/core.py +272 -0
- ameva_vulkan_runtime/doctor.py +900 -0
- ameva_vulkan_runtime/exceptions.py +32 -0
- ameva_vulkan_runtime/platform.py +270 -0
- ameva_vulkan_runtime/profiles/validated-vulkan-profiles.json +213 -0
- ameva_vulkan_runtime/protocol.py +125 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AMEVA Runtime (Unified Next-Gen On-Device AI Runtime)
|
|
3
|
+
=====================================================
|
|
4
|
+
Multi-backend hardware orchestration (Vulkan, OpenCL, NPU, CPU-NEON)
|
|
5
|
+
for mobile & edge devices.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from .core import (
|
|
10
|
+
AmevaRuntime,
|
|
11
|
+
get_runtime,
|
|
12
|
+
VulkanContext,
|
|
13
|
+
create_context,
|
|
14
|
+
get_or_create_context,
|
|
15
|
+
run,
|
|
16
|
+
plan,
|
|
17
|
+
ExecutionResult,
|
|
18
|
+
)
|
|
19
|
+
from .detector import detect_hardware, HardwareProfile
|
|
20
|
+
from .router import SmartRouter, ExecutionPlan, get_router
|
|
21
|
+
from .doctor import Doctor, DiagnosticReport, diagnose
|
|
22
|
+
from .protocol import IRuntimeConsumer, IVulkanConsumer, BindingResult
|
|
23
|
+
from .exceptions import (
|
|
24
|
+
AmevaRuntimeError,
|
|
25
|
+
HardwareDetectionError,
|
|
26
|
+
SubsystemInitError,
|
|
27
|
+
DriverLockupError,
|
|
28
|
+
DeviceOOMError,
|
|
29
|
+
ArchitectureUnsupportedError,
|
|
30
|
+
InvalidAffinityError,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
__version__ = "1.0.0"
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"__version__",
|
|
37
|
+
"AmevaRuntime",
|
|
38
|
+
"get_runtime",
|
|
39
|
+
"run",
|
|
40
|
+
"plan",
|
|
41
|
+
"ExecutionResult",
|
|
42
|
+
"VulkanContext",
|
|
43
|
+
"create_context",
|
|
44
|
+
"get_or_create_context",
|
|
45
|
+
"detect_hardware",
|
|
46
|
+
"HardwareProfile",
|
|
47
|
+
"SmartRouter",
|
|
48
|
+
"ExecutionPlan",
|
|
49
|
+
"get_router",
|
|
50
|
+
"Doctor",
|
|
51
|
+
"DiagnosticReport",
|
|
52
|
+
"diagnose",
|
|
53
|
+
"IRuntimeConsumer",
|
|
54
|
+
"IVulkanConsumer",
|
|
55
|
+
"BindingResult",
|
|
56
|
+
"AmevaRuntimeError",
|
|
57
|
+
"HardwareDetectionError",
|
|
58
|
+
"SubsystemInitError",
|
|
59
|
+
"DriverLockupError",
|
|
60
|
+
"DeviceOOMError",
|
|
61
|
+
"ArchitectureUnsupportedError",
|
|
62
|
+
"InvalidAffinityError",
|
|
63
|
+
]
|
|
64
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AMEVA Modality Adapters
|
|
3
|
+
=======================
|
|
4
|
+
Adapters connecting individual uno-km AI modalities to the smart runtime.
|
|
5
|
+
"""
|
|
6
|
+
from .base import BindingResult, find_system_vulkan_driver_dir
|
|
7
|
+
from .llamacpp import LlamaCppAdapter
|
|
8
|
+
from .vision import VisionAdapter
|
|
9
|
+
from .diffusion import DiffusionAdapter
|
|
10
|
+
from .stt import SttAdapter
|
|
11
|
+
from .tts import TtsAdapter
|
|
12
|
+
from .bitnet import BitnetAdapter
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"BindingResult",
|
|
16
|
+
"find_system_vulkan_driver_dir",
|
|
17
|
+
"LlamaCppAdapter",
|
|
18
|
+
"VisionAdapter",
|
|
19
|
+
"DiffusionAdapter",
|
|
20
|
+
"SttAdapter",
|
|
21
|
+
"TtsAdapter",
|
|
22
|
+
"BitnetAdapter",
|
|
23
|
+
]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ameva_runtime.adapters.base
|
|
3
|
+
===========================
|
|
4
|
+
Base Utilities and Shared Helper Functions for AMEVA Modality Adapters.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any, Optional, Dict
|
|
13
|
+
|
|
14
|
+
from ..protocol import BindingResult
|
|
15
|
+
from ..detector import detect_hardware, HardwareProfile
|
|
16
|
+
from ..router import get_router, SmartRouter
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger("ameva_runtime.adapters")
|
|
19
|
+
|
|
20
|
+
_ADRENO_VENDOR_ID = 0x5143
|
|
21
|
+
_MALI_VENDOR_ID = 0x13B5
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _is_vulkan_viable(profile: HardwareProfile) -> bool:
|
|
25
|
+
"""Returns True if Vulkan execution is genuinely safe without driver lockup."""
|
|
26
|
+
return profile.recommended_backend == "vulkan" and not profile.hardware_hazard
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _make_adaptive_binding(
|
|
30
|
+
module: str,
|
|
31
|
+
profile: HardwareProfile,
|
|
32
|
+
config: Dict[str, Any],
|
|
33
|
+
backend: str = "cpu_neon",
|
|
34
|
+
status: str = "BOUND_ADAPTIVE",
|
|
35
|
+
) -> BindingResult:
|
|
36
|
+
"""Creates a transparent BindingResult adhering to Zero-Silent-Fallback."""
|
|
37
|
+
logger.info(
|
|
38
|
+
"[ameva-runtime:%s] Active Backend: %s (Reason: %s)",
|
|
39
|
+
module, backend, profile.diagnosis_reason
|
|
40
|
+
)
|
|
41
|
+
config["backend"] = backend
|
|
42
|
+
config["diagnosis"] = profile.diagnosis_reason
|
|
43
|
+
is_vk = (backend == "vulkan")
|
|
44
|
+
return BindingResult(
|
|
45
|
+
module=module,
|
|
46
|
+
backend=backend,
|
|
47
|
+
is_vulkan=is_vk,
|
|
48
|
+
device_name=profile.gpu_family,
|
|
49
|
+
vendor_id=_MALI_VENDOR_ID if profile.gpu_family == "mali" else _ADRENO_VENDOR_ID,
|
|
50
|
+
config=config,
|
|
51
|
+
status=status,
|
|
52
|
+
diagnosis=profile.diagnosis_reason,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def find_system_vulkan_driver_dir() -> Optional[str]:
|
|
57
|
+
"""Dynamically finds the directory containing the active libvulkan.so."""
|
|
58
|
+
is_64bit = sys.maxsize > 2**32
|
|
59
|
+
candidates = [
|
|
60
|
+
Path("/system/lib64" if is_64bit else "/system/lib"),
|
|
61
|
+
Path("/vendor/lib64" if is_64bit else "/vendor/lib"),
|
|
62
|
+
Path("/apex/com.android.runtime/lib64" if is_64bit else "/apex/com.android.runtime/lib"),
|
|
63
|
+
]
|
|
64
|
+
for c in candidates:
|
|
65
|
+
if (c / "libvulkan.so").exists():
|
|
66
|
+
return str(c.resolve())
|
|
67
|
+
return None
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
BitnetAdapter — termux-bitnet (1-bit LLM) Acceleration Adapter
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from ..protocol import BindingResult
|
|
10
|
+
from ..detector import detect_hardware, HardwareProfile
|
|
11
|
+
from .base import _make_adaptive_binding
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger("ameva_runtime.adapters.bitnet")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class BitnetAdapter:
|
|
17
|
+
"""termux-bitnet acceleration adapter."""
|
|
18
|
+
|
|
19
|
+
module_name = "termux-bitnet"
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def bind(engine: Any = None, profile: Any = None) -> BindingResult:
|
|
23
|
+
if not isinstance(profile, HardwareProfile):
|
|
24
|
+
profile = detect_hardware()
|
|
25
|
+
|
|
26
|
+
config: dict = {
|
|
27
|
+
"module": BitnetAdapter.module_name,
|
|
28
|
+
"device_name": profile.gpu_family,
|
|
29
|
+
"backend": "cpu_neon", # BitNet is natively optimized for CPU 1-bit LUTs
|
|
30
|
+
"threads": profile.recommended_threads,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if engine is not None:
|
|
34
|
+
try:
|
|
35
|
+
if hasattr(engine, "threads"):
|
|
36
|
+
engine.threads = profile.recommended_threads
|
|
37
|
+
except Exception as e:
|
|
38
|
+
logger.warning("Failed to configure BitNet engine: %s", e)
|
|
39
|
+
|
|
40
|
+
return _make_adaptive_binding(
|
|
41
|
+
module=BitnetAdapter.module_name,
|
|
42
|
+
profile=profile,
|
|
43
|
+
config=config,
|
|
44
|
+
backend="cpu_neon",
|
|
45
|
+
status="BOUND_CPU_NEON",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def unbind() -> None:
|
|
50
|
+
pass
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DiffusionAdapter — termux-diffusion (Stable Diffusion / Onnx / NCNN) Acceleration Adapter
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from ..protocol import BindingResult
|
|
10
|
+
from ..detector import detect_hardware, HardwareProfile
|
|
11
|
+
from .base import _make_adaptive_binding
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger("ameva_runtime.adapters.diffusion")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DiffusionAdapter:
|
|
17
|
+
"""termux-diffusion acceleration adapter."""
|
|
18
|
+
|
|
19
|
+
module_name = "termux-diffusion"
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def bind(engine: Any = None, profile: Any = None) -> BindingResult:
|
|
23
|
+
if not isinstance(profile, HardwareProfile):
|
|
24
|
+
profile = detect_hardware()
|
|
25
|
+
|
|
26
|
+
is_vk = profile.recommended_backend == "vulkan"
|
|
27
|
+
config: dict = {
|
|
28
|
+
"module": DiffusionAdapter.module_name,
|
|
29
|
+
"device_name": profile.gpu_family,
|
|
30
|
+
"backend": "vulkan" if is_vk else "cpu_neon",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if engine is not None:
|
|
34
|
+
try:
|
|
35
|
+
if hasattr(engine, "device"):
|
|
36
|
+
engine.device = "vulkan" if is_vk else "cpu"
|
|
37
|
+
except Exception as e:
|
|
38
|
+
logger.warning("Failed to configure diffusion engine: %s", e)
|
|
39
|
+
|
|
40
|
+
return _make_adaptive_binding(
|
|
41
|
+
module=DiffusionAdapter.module_name,
|
|
42
|
+
profile=profile,
|
|
43
|
+
config=config,
|
|
44
|
+
backend="vulkan" if is_vk else "cpu_neon",
|
|
45
|
+
status="BOUND_VULKAN" if is_vk else "BOUND_CPU_NEON",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def unbind() -> None:
|
|
50
|
+
pass
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ameva_runtime.adapters.llamacpp
|
|
3
|
+
===============================
|
|
4
|
+
Adapter for termux-llamacpp (GGUF LLM) inference.
|
|
5
|
+
Integrates with SmartRouter to provide Zero-Crash adaptive execution.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from ..protocol import BindingResult
|
|
14
|
+
from ..detector import detect_hardware, HardwareProfile
|
|
15
|
+
from ..router import SmartRouter, ExecutionPlan
|
|
16
|
+
from .base import _make_adaptive_binding
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger("ameva_runtime.adapters.llamacpp")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class LlamaCppAdapter:
|
|
22
|
+
"""termux-llamacpp execution and acceleration adapter."""
|
|
23
|
+
|
|
24
|
+
module_name = "termux-llamacpp"
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def bind(engine: Any = None, profile: Any = None) -> BindingResult:
|
|
28
|
+
if isinstance(profile, HardwareProfile):
|
|
29
|
+
prof = profile
|
|
30
|
+
else:
|
|
31
|
+
prof = detect_hardware()
|
|
32
|
+
|
|
33
|
+
router = SmartRouter(prof)
|
|
34
|
+
plan: ExecutionPlan = router.route_for_llm()
|
|
35
|
+
|
|
36
|
+
config: dict = {
|
|
37
|
+
"module": LlamaCppAdapter.module_name,
|
|
38
|
+
"backend": plan.backend,
|
|
39
|
+
"ngl": plan.ngl,
|
|
40
|
+
"threads": plan.threads,
|
|
41
|
+
"cli_flags": plan.cli_flags,
|
|
42
|
+
"allowed_cpus": plan.allowed_cpus,
|
|
43
|
+
"is_gpu": plan.is_gpu_accelerated,
|
|
44
|
+
"diagnosis": plan.diagnosis,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Apply environment overrides
|
|
48
|
+
for k, v in plan.env_overrides.items():
|
|
49
|
+
os.environ[k] = v
|
|
50
|
+
|
|
51
|
+
if engine is not None:
|
|
52
|
+
try:
|
|
53
|
+
if isinstance(engine, dict):
|
|
54
|
+
engine["ngl"] = plan.ngl
|
|
55
|
+
engine["threads"] = plan.threads
|
|
56
|
+
engine["backend"] = plan.backend
|
|
57
|
+
engine.setdefault("cli_flags", []).extend(plan.cli_flags)
|
|
58
|
+
engine.setdefault("env", {}).update(plan.env_overrides)
|
|
59
|
+
elif hasattr(engine, "config"):
|
|
60
|
+
cfg = engine.config
|
|
61
|
+
if isinstance(cfg, dict):
|
|
62
|
+
cfg["ngl"] = plan.ngl
|
|
63
|
+
cfg["n_gpu_layers"] = plan.ngl
|
|
64
|
+
cfg["threads"] = plan.threads
|
|
65
|
+
cfg["backend"] = plan.backend
|
|
66
|
+
else:
|
|
67
|
+
if hasattr(cfg, "ngl"):
|
|
68
|
+
cfg.ngl = plan.ngl
|
|
69
|
+
if hasattr(cfg, "n_gpu_layers"):
|
|
70
|
+
cfg.n_gpu_layers = plan.ngl
|
|
71
|
+
if hasattr(cfg, "threads"):
|
|
72
|
+
cfg.threads = plan.threads
|
|
73
|
+
if hasattr(cfg, "device"):
|
|
74
|
+
cfg.device = "vulkan" if plan.is_gpu_accelerated else "cpu"
|
|
75
|
+
except Exception as e:
|
|
76
|
+
logger.warning("Failed to inject configuration into engine: %s", e)
|
|
77
|
+
|
|
78
|
+
return _make_adaptive_binding(
|
|
79
|
+
module=LlamaCppAdapter.module_name,
|
|
80
|
+
profile=profile,
|
|
81
|
+
config=config,
|
|
82
|
+
backend=plan.backend,
|
|
83
|
+
status="BOUND_VULKAN" if plan.is_gpu_accelerated else "BOUND_CPU_NEON",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def unbind() -> None:
|
|
88
|
+
pass
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SttAdapter — termux-stt (Whisper) Acceleration Adapter
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from ..protocol import BindingResult
|
|
10
|
+
from ..detector import detect_hardware, HardwareProfile
|
|
11
|
+
from .base import _make_adaptive_binding
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger("ameva_runtime.adapters.stt")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SttAdapter:
|
|
17
|
+
"""termux-stt acceleration adapter."""
|
|
18
|
+
|
|
19
|
+
module_name = "termux-stt"
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def bind(engine: Any = None, profile: Any = None) -> BindingResult:
|
|
23
|
+
if not isinstance(profile, HardwareProfile):
|
|
24
|
+
profile = detect_hardware()
|
|
25
|
+
|
|
26
|
+
is_vk = profile.recommended_backend == "vulkan"
|
|
27
|
+
config: dict = {
|
|
28
|
+
"module": SttAdapter.module_name,
|
|
29
|
+
"device_name": profile.gpu_family,
|
|
30
|
+
"backend": "vulkan" if is_vk else "cpu_neon",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if engine is not None:
|
|
34
|
+
try:
|
|
35
|
+
if hasattr(engine, "device"):
|
|
36
|
+
engine.device = "vulkan" if is_vk else "cpu"
|
|
37
|
+
except Exception as e:
|
|
38
|
+
logger.warning("Failed to configure STT engine: %s", e)
|
|
39
|
+
|
|
40
|
+
return _make_adaptive_binding(
|
|
41
|
+
module=SttAdapter.module_name,
|
|
42
|
+
profile=profile,
|
|
43
|
+
config=config,
|
|
44
|
+
backend="vulkan" if is_vk else "cpu_neon",
|
|
45
|
+
status="BOUND_VULKAN" if is_vk else "BOUND_CPU_NEON",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def unbind() -> None:
|
|
50
|
+
pass
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TtsAdapter — termux-tts (Piper / Kokoro) Acceleration Adapter
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from ..protocol import BindingResult
|
|
10
|
+
from ..detector import detect_hardware, HardwareProfile
|
|
11
|
+
from .base import _make_adaptive_binding
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger("ameva_runtime.adapters.tts")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TtsAdapter:
|
|
17
|
+
"""termux-tts acceleration adapter."""
|
|
18
|
+
|
|
19
|
+
module_name = "termux-tts"
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def bind(engine: Any = None, profile: Any = None) -> BindingResult:
|
|
23
|
+
if not isinstance(profile, HardwareProfile):
|
|
24
|
+
profile = detect_hardware()
|
|
25
|
+
|
|
26
|
+
is_vk = profile.recommended_backend == "vulkan"
|
|
27
|
+
config: dict = {
|
|
28
|
+
"module": TtsAdapter.module_name,
|
|
29
|
+
"device_name": profile.gpu_family,
|
|
30
|
+
"backend": "vulkan" if is_vk else "cpu_neon",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if engine is not None:
|
|
34
|
+
try:
|
|
35
|
+
if hasattr(engine, "device"):
|
|
36
|
+
engine.device = "vulkan" if is_vk else "cpu"
|
|
37
|
+
except Exception as e:
|
|
38
|
+
logger.warning("Failed to configure TTS engine: %s", e)
|
|
39
|
+
|
|
40
|
+
return _make_adaptive_binding(
|
|
41
|
+
module=TtsAdapter.module_name,
|
|
42
|
+
profile=profile,
|
|
43
|
+
config=config,
|
|
44
|
+
backend="vulkan" if is_vk else "cpu_neon",
|
|
45
|
+
status="BOUND_VULKAN" if is_vk else "BOUND_CPU_NEON",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def unbind() -> None:
|
|
50
|
+
pass
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""
|
|
2
|
+
VisionAdapter — termux-vision (LLaVA ViT / YOLO) Acceleration Adapter
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from ..protocol import BindingResult
|
|
10
|
+
from ..detector import detect_hardware, HardwareProfile
|
|
11
|
+
from .base import _make_adaptive_binding
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger("ameva_runtime.adapters.vision")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class VisionAdapter:
|
|
17
|
+
"""termux-vision (LLaVA ViT / SmolVLM / YOLO) acceleration adapter."""
|
|
18
|
+
|
|
19
|
+
module_name = "termux-vision"
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def bind(engine: Any = None, profile: Any = None) -> BindingResult:
|
|
23
|
+
if not isinstance(profile, HardwareProfile):
|
|
24
|
+
profile = detect_hardware()
|
|
25
|
+
|
|
26
|
+
is_vk = profile.recommended_backend == "vulkan"
|
|
27
|
+
config: dict = {
|
|
28
|
+
"module": VisionAdapter.module_name,
|
|
29
|
+
"device_name": profile.gpu_family,
|
|
30
|
+
"backend": "vulkan" if is_vk else "cpu_neon",
|
|
31
|
+
"vit_acceleration": is_vk,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if engine is not None:
|
|
35
|
+
try:
|
|
36
|
+
if hasattr(engine, "device"):
|
|
37
|
+
engine.device = "vulkan" if is_vk else "cpu"
|
|
38
|
+
except Exception as e:
|
|
39
|
+
logger.warning("Failed to configure vision engine: %s", e)
|
|
40
|
+
|
|
41
|
+
return _make_adaptive_binding(
|
|
42
|
+
module=VisionAdapter.module_name,
|
|
43
|
+
profile=profile,
|
|
44
|
+
config=config,
|
|
45
|
+
backend="vulkan" if is_vk else "cpu_neon",
|
|
46
|
+
status="BOUND_VULKAN" if is_vk else "BOUND_CPU_NEON",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def unbind() -> None:
|
|
51
|
+
pass
|