Spaces:
Configuration error
Configuration error
File size: 529 Bytes
f1ba785 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | """Optional CUDA critical section. The line process binds the shared gate."""
from __future__ import annotations
from collections.abc import Callable
from typing import TypeVar
T = TypeVar("T")
Runner = Callable[[Callable[[], T]], tuple[T, float]]
_runner: Runner | None = None
def bind_gpu_runner(runner: Runner) -> None:
global _runner
_runner = runner
def gpu_call(fn: Callable[[], T]) -> T:
if _runner is None:
return fn()
value, _wait_ms = _runner(fn)
return value
|