Spaces:
Configuration error
Configuration error
Download axis_numeric/gpu_exec.py from serety95/axis-numeric: direct link, hf CLI and curl.
- Browser
- Download file 529 Bytes
-
https://huggingface.co/spaces/serety95/axis-numeric/resolve/main/axis_numeric/gpu_exec.py
- Command line
-
hf download hf://spaces/serety95/axis-numeric/axis_numeric/gpu_exec.py
-
curl -L -o gpu_exec.py https://huggingface.co/spaces/serety95/axis-numeric/resolve/main/axis_numeric/gpu_exec.py
529 Bytes
| """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 | |