INNER CODE UNIT · Python
_TinygradProxy
onnxsim/onnxsim · onnxsim/rpc/server.py:235
class _TinygradProxy:
"""A tinygrad model living in its own worker process.
One process per loaded model means every (device, codegen options) pair starts from clean
kernel and schedule caches -- so a ``BEAM`` setting really applies instead of silently reusing
kernels compiled earlier under another setting -- tinygrad's thread-bound state (its SQLite
disk cache, device contexts) stays on the worker's main thread, and a GPU fault cannot take
the server down.
"""
def __init__(
self, model_bytes: bytes, device: Optional[str], options, work_dir: str
):
import importlib.util
import multiprocessing
if importlib.util.find_spec("tinygrad") is None:
raise proto.RPCError(