INNER CODE UNIT · Python
unknown
onnxsim/onnxsim · onnxsim/rpc/server.py:113
unknown = sorted(set(options) - set(self.ALLOWED_OPTIONS))
if unknown:
raise proto.RPCError(
f"unsupported tinygrad options {unknown}; allowed: {list(self.ALLOWED_OPTIONS)}"
)
self.options = {k: int(v) for k, v in options.items()}
self.device = device or Device.DEFAULT
self._Tensor, self._Device = Tensor, Device
model = model_bytes_to_proto(model_bytes)
self.output_names = [o.name for o in model.graph.output]
handle, path = tempfile.mkstemp(suffix=".onnx", dir=work_dir)
try:
with os.fdopen(handle, "wb") as f:
f.write(model_bytes)
# Weights are created on tinygrad's default device: scope it to the requested one.
with self._scope():
self.runner = OnnxRunner(path)
finally: