onnx: Version converter 11 -> 12 fails with "IndexError: Input s is undefined!"

Bug Report

Describe the bug

The version converter fails on the attached model (and not becase the adapter is missing)

System information

  • OS Platform and Distribution: Ubuntu 18.04
  • ONNX version: 1.7 release commit
  • Python version: 3.6.9
  • GCC/Compiler version: 7.5.0
  • CMake version: 3.17.3
  • Protobuf version: 3.12

Reproduction instructions

import onnx
from onnx import version_converter, helper

# Preprocessing: load the model to be converted.
model_path = "path/to/shared-bn-arrays-v11.onnx"
original_model = onnx.load(model_path)

converted_model = version_converter.convert_version(original_model, 12)
print("done!")

The script doesn’t get to the final print, but fails with

Traceback (most recent call last):
  File "script.py", line 8, in <module>
    converted_model = version_converter.convert_version(original_model, 12)
  File "/usr/local/lib/python3.6/dist-packages/onnx-1.7.0-py3.6-linux-x86_64.egg/onnx/version_converter.py", line 166, in convert_version
    converted_model_str = C.convert_version(model_str, target_version)
IndexError: Input s is undefined!

Expected behavior

The script should not fail and properly upgrade the model (or at least fail saying there are no adapters)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (13 by maintainers)

Most upvoted comments

still not working, even with IR 6 and latest code on master today, and the fix proposed…

I tried with workaround too but still not working. Conversion fails from opset10 --> Opset13 using ONNX 1.10.1.

converted_model_str = C.convert_version(model_str, target_version) IndexError: Input conv1.conv2d.weight is undefined!

Hi @ZhangXiaoying0116, Thank you for catching this! I referenced a wrong code… This one should be the right one: https://github.com/onnx/onnx/issues/2995#issuecomment-687631931 (add_input_from_initializer). I will correct my response above as well.