TensorRT 5.1.6.1 ONNX Parser cannot parse an ONNX model produced by tf2onnx

Hi everyone,

So, I have been using Tensorflow 1.13 and have no problems parsing converted TF 1.13 to ONNX models (by tf2onnx) using TensorRT 6.0.1.5 on my Windows/Linux laptop.

I have flashed my Jetson Nano memory card using the latest JetPack (TensorRT 5.1.6.1) and the ONNX parser cannot seem to be able to parse my models. I have tried using TF 1.12 to train a model, tf2onnx to convert the model to the ONNX format but I am still getting the same error. The error is as follows:

ONNX IR version: 0.0.6
Opset version: 7
Producer name: tf2onnx
Producer version: 1.5.3
Domain:
Model version: 0
Doc string:

WARNING: ONNX model has a newer ir_version (0.0.6) than this parser was built against (0.0.3).
While parsing node number 0 [Mul]:
ERROR: builtin_op_importers.cpp:353 In function importScaleOp:
[8] Assertion failed: get_shape_size(weights.shape) == get_shape_size(dims)
Parsing the ONNX model failed.

Could you, please help me figure out what the problem is ?

Thanks :)

Hi,

Do you have a toy model can reproduce this issue?

Thanks.

Hi AastaLLL,

I did some debugging and testing myself and this is what I found out.

The following multiplication operation was causing the problem (I am providing a code snippet to make it easier to understand what gets multiplied by what):

inpImgShape = [480, 640, 3]
inpImgPH = tf.placeholder(tf.float32, shape=[None, *inpImgShape], name = “Input”)
normVal = tf.constant(1.0 / 255.0, shape=)
normInput = tf.math.multiply(normVal, inpImgPH) <— this caused the parsing problem using TensorRT 5.1.6.1

I thought about it and figured I could try to calculate normInput as:

normInput = inpImgPH / 255.0

and it worked !!! :)

Let me know if this is enough information for you to track down a possible problem in the TensorRT 5.1.6.1 parser code. Also, I use tf2onnx to convert my TF models to ONNX and so I am not sure if the way it converts these two different calculation methods might be the reason why the TensorRT 5.1.6.1 parser cannot process the first method (as a reminder, the TensorRT 6.0.1.5 parses the first method correctly on a Win/Linux desktop).

Thanks :)