# Issue With relay.frontend.from\_onnx() when using Bert

**URL:** <https://discuss.tvm.apache.org/t/issue-with-relay-frontend-from-onnx-when-using-bert/8622>\
**Category:** Troubleshooting\
**Created:** [December 9, 2020, 11:03am UTC](https://discuss.tvm.apache.org/t/issue-with-relay-frontend-from-onnx-when-using-bert/8622 "2020-12-09T11:03:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheoG](https://discuss.tvm.apache.org/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@TheoG](https://discuss.tvm.apache.org/u/TheoG)\
**Post date:** [December 9, 2020, 11:03am UTC](https://discuss.tvm.apache.org/t/issue-with-relay-frontend-from-onnx-when-using-bert/8622/1 "2020-12-09T11:03:06Z")

</div>

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.
