Skip to content

Commit fceaf88

Browse files
authored
Merge branch 'main' into new_provider
2 parents da80a9b + 41dcd5f commit fceaf88

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

backends/tvm/backend.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ def _native_ops_only(model):
4040
def _tvm_worker(model_bytes, inputs, input_names, output_count, result_queue):
4141
"""Compile and run an ONNX model via TVM Relay in an isolated subprocess."""
4242
import onnx
43-
import tvm
44-
from tvm import relay
45-
from tvm.contrib import graph_executor
43+
44+
try:
45+
import tvm
46+
from tvm import relay
47+
from tvm.contrib import graph_executor
48+
except (ImportError, AttributeError, OSError, RuntimeError) as e:
49+
msg = f"tvm import failed: {type(e).__name__}: {e}"
50+
print(f"[tvm] SKIP {msg}", file=sys.stderr, flush=True)
51+
result_queue.put(("error", msg))
52+
return
4653

4754
model = onnx.ModelProto()
4855
model.ParseFromString(model_bytes)
@@ -68,7 +75,14 @@ def _tvm_worker(model_bytes, inputs, input_names, output_count, result_queue):
6875
module.run()
6976
outputs = [module.get_output(i).numpy() for i in range(output_count)]
7077
result_queue.put(("ok", outputs))
71-
except (tvm.TVMError, RuntimeError, ValueError, TypeError, OSError) as e:
78+
except (
79+
tvm.TVMError,
80+
RuntimeError,
81+
ValueError,
82+
TypeError,
83+
OSError,
84+
ImportError,
85+
) as e:
7286
ops = sorted({n.op_type for n in model.graph.node})
7387
msg = f"ops={ops} error={type(e).__name__}: {e}"
7488
print(f"[tvm] SKIP {msg}", file=sys.stderr, flush=True)

runtimes/tvm/stable/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ ENV PYTHONPATH="/root"
2727
# Set locale and install TVM and onnx
2828
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 && \
2929
pip3 install \
30-
onnx \
30+
"numpy<2" \
31+
"onnx<1.19" \
3132
apache-tvm
3233
####################################################
3334

0 commit comments

Comments
 (0)