Issue With relay.frontend.from_onnx() when using Bert

Hi all,

I’m new to TVM and I’m trying to import a BERT NLP model from onnx using from_onnx from the tvm frontend.

When attempting to use from_onnx however, I get the following error saying that it expects an ‘Array[PrimExpr] but get Array’ :

File “tvm-onnx.py”, line 82, in mods, params = relay.frontend.from_onnx(onnx_model, shape_dict) File “/home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/frontend/onnx.py”, line 2420, in from_onnx mod, params = g.from_onnx(graph, opset) File “/home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/frontend/onnx.py”, line 2209, in from_onnx self._nodes[i_name] = new_var(i_name, shape=tshape, dtype=dtype) File “/home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/frontend/common.py”, line 557, in new_var return _expr.var(name_hint, type_annotation, shape, dtype) File “/home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/expr.py”, line 464, in var type_annotation = _ty.TensorType(shape, dtype) File “/home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/ir/tensor_type.py”, line 41, in init _ffi_api.TensorType, shape, dtype) File “tvm/_ffi/_cython/./object.pxi”, line 126, in tvm._ffi._cy3.core.ObjectBase.init_handle_by_constructor File “tvm/_ffi/_cython/./packed_func.pxi”, line 278, in tvm._ffi._cy3.core.ConstructorCall File “tvm/_ffi/_cython/./packed_func.pxi”, line 256, in tvm._ffi._cy3.core.FuncCall File “tvm/_ffi/_cython/./packed_func.pxi”, line 245, in tvm._ffi._cy3.core.FuncCall3 File “tvm/_ffi/_cython/./base.pxi”, line 160, in tvm._ffi._cy3.core.CALL tvm.ffi.base.TVMError: Traceback (most recent call last): [bt] (3) /home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/libtvm.so(TVMFuncCall+0x4c) [0xffff8f1fac3c] [bt] (2) /home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/libtvm.so(+0x575e78) [0xffff8ea27e78] [bt] (1) /home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/libtvm.so(tvm::runtime::Array<tvm::PrimExpr, void> tvm::runtime::TVMPODValue::AsObjectRef<tvm::runtime::Array<tvm::PrimExpr, void> >() const+0x2dc) [0xffff8e906284] [bt] (0) /home/theo/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/libtvm.so(+0x44c214) [0xffff8e8fe214] File “/home/theo/tvm-theo/tvm/include/tvm/runtime/packed_func.h”, line 1402 TVMError: Check failed: ObjectTypeChecker: :Check(ptr): Expect Array[PrimExpr] but get Array

Below is a snippet of the relevant code:

max_sequence_length = 512 batch = ‘N’

shape_dict = { ‘attention_mask’: (batch, max_sequence_length), ‘input_ids’: (batch, max_sequence_length0, ‘token_type_ids’: (batch, max_sequence_length) }

mods, params = relay.frontend.from_onnx(onnx_model, shape_dict)

I’m a bit stumped by this so if there’s any advice I’d appreciate it.