interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / bin / oal-run

27 lines · 1269 bytes Raw Blame History
1#!/usr/bin/env python3
2# SPDX-License-Identifier: Apache-2.0
3# oal-run BACKEND WORKLOAD < case.bin > outputs.bin
4# Build and run one entrant on one case. stdout: the entrant's output tensors; stderr: its log and a
5# final JSON status line. Exit 0 ran, 2 compile failure, 3 runtime failure or timeout, 4 NOT_RUN,
6# 5 NO_SOURCE, 6 COMPILED (built, not run).
7# INTERIM host glue (Python). Successor: oal-run in seeded Omega.
8import os
9import sys
10sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
11import json
12from oal import case, manifest, run
13
14if len(sys.argv) != 3 or sys.argv[1] not in run.BACKENDS:
15 sys.stderr.write("usage: oal-run {%s} WORKLOAD < case > outputs\n" % ",".join(run.BACKENDS))
16 sys.exit(2)
17backend, name = sys.argv[1], sys.argv[2]
18m = manifest.load(name)
19blob = sys.stdin.buffer.read()
20pvals = case.unpack(blob)[0]
21params = dict(zip(manifest.params_of(m).keys(), pvals))
22r = run.execute(backend, m, params, blob, int(os.environ.get("OAL_TIMEOUT", "600")))
23if r.get("outputs") is not None:
24 sys.stdout.buffer.write(r.pop("outputs"))
25sys.stderr.write(json.dumps(r) + "\n")
26sys.exit({"RAN": 0, "COMPILE_FAIL": 2, "RUNTIME_FAIL": 3, "TIMEOUT": 3, "NOT_RUN": 4, "NO_SOURCE": 5,
27 "COMPILED": 6}[r["status"]])