Coverage for src/flag_gems/runtime/backend/_spacemit/__init__.py: 0%
32 statements
« prev ^ index » next coverage.py v7.6.9, created at 2026-06-05 07:36 +0800
« prev ^ index » next coverage.py v7.6.9, created at 2026-06-05 07:36 +0800
1import importlib.util
2from typing import Any
4from backend_utils import VendorInfoBase # noqa: E402
6if importlib.util.find_spec("triton.backends.spine_triton") is not None:
7 from .utils.config_pre_hook import setup_triton_config
9 setup_triton_config()
11 import triton # noqa: E402
12 from triton.backends.spine_triton.driver import CPUDriver # noqa: E402
14 triton.runtime.driver.set_active(CPUDriver()) # noqa: E402
17vendor_info = VendorInfoBase(
18 vendor_name="spacemit",
19 device_name="cpu",
20 device_query_cmd="spacemit-tcm-smi",
21)
24class _DeviceGuard:
25 def __init__(self, index: int):
26 self.idx = index
27 self.prev_idx = -1
29 def __enter__(self):
30 self.prev_idx = self.idx
32 def __exit__(self, type: Any, value: Any, traceback: Any):
33 self.idx = self.prev_idx
34 return False
37class _DeviceWrapper:
38 def __init__(self, device: Any):
39 ...
41 def __enter__(self):
42 ...
44 def __exit__(self, type: Any, value: Any, traceback: Any):
45 ...
46 return False
48 @staticmethod
49 def current_device():
50 """Return device index for kernel cache. CPU backend always uses device 0."""
51 return 0
54CUSTOMIZED_UNUSED_OPS = ()
57__all__ = ["*"]