Skip to content

Commit

Permalink
[ONNX Parser] Add warning in case of opset mismatch (apache#8356)
Browse files Browse the repository at this point in the history
* add warning in case of opset mismatch

* fix CI

Co-authored-by: elenaslavutina <elena.slavutina2013@gmail.com>
  • Loading branch information
2 people authored and ylc committed Jan 13, 2022
1 parent 54ae18e commit 0725a57
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3722,11 +3722,21 @@ def from_onnx(model, shape=None, dtype="float32", opset=None, freeze_params=Fals
pass
g = GraphProto(shape, dtype, freeze_params)
graph = model.graph

try:
opset_in_model = model.opset_import[0].version if model.opset_import else 1
except AttributeError:
opset_in_model = 1

if opset is None:
try:
opset = model.opset_import[0].version if model.opset_import else 1
except AttributeError:
opset = 1
opset = opset_in_model
elif opset < opset_in_model:
warnings.warn(
""
f"You are overwritting original opset ver = {opset_in_model} by lower ver = {opset}. "
f"That might cause model conversion errors."
)

# Use the graph proto as a scope so that ops can access other nodes if needed.
with g:
mod, params = g.from_onnx(graph, opset)
Expand Down

0 comments on commit 0725a57

Please sign in to comment.