INNER CODE UNIT · Python
result
onnxsim/onnxsim · onnxsim/rpc/server.py:229
result = getattr(runner, request[0])(*request[1:])
connection.send(("ok", result))
except BaseException as error: # noqa: BLE001
connection.send(("error", f"{type(error).__name__}: {error}"))
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