INNER CODE UNIT · Python

_TinygradRunner

onnxsim/onnxsim · onnxsim/rpc/server.py:83

class _TinygradRunner:
    """Runs a model with tinygrad's ONNX frontend on a chosen tinygrad device.

    Exists so tinygrad's code generation can be benchmarked on the server's hardware through the
    same session API. ``options`` are tinygrad codegen knobs (an allow-list, e.g. ``{"BEAM": 2}``)
    applied around compilation and execution. The frontend caches Python constants between calls,
    so this suits static-shape models; a graph with data-dependent shapes needs a fresh load per
    input.
    """

    ALLOWED_OPTIONS = ("BEAM", "NOOPT")
    DEVICE_PATTERN = re.compile(r"^[A-Z][A-Z0-9_]*(:[0-9]+)?$")

    def __init__(
        self,
        model_bytes: bytes,
        device: Optional[str],
        options: Optional[Dict[str, Any]],

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…