INNER CODE UNIT · Python
_tinygrad_worker
onnxsim/onnxsim · onnxsim/rpc/server.py:213
def _tinygrad_worker(connection, model_bytes, device, options, work_dir) -> None:
"""Entry point of a tinygrad worker process: build the runner, then serve run/time requests."""
try:
runner = _TinygradRunner(model_bytes, device, options, work_dir)
connection.send(("ok", None))
except BaseException as error: # noqa: BLE001 - relayed to the parent
connection.send(("error", f"{type(error).__name__}: {error}"))
return
while True:
try:
request = connection.recv()
except EOFError:
return
if request[0] == "close":
return
try:
result = getattr(runner, request[0])(*request[1:])
connection.send(("ok", result))