onnx-tensorrt
onnx-tensorrt copied to clipboard
Parser does not provide the correct output dimension
Hello, I was trying to import a model exported with tensorflow that has output size (batch_size, 2) however the parser returns an output dimension of (-1,-1).
Here is the output of the logger in verbose mode:
ModelImporter.cpp:125: resnet_model/out_layer/MatMul [MatMul] inputs: [resnet_model/dropout_2/Identity:0 -> (-1, 512)], [resnet_model/out_layer/MatMul/ReadVariableOp__273 -> (512, 2)], ImporterContext.hpp:150: Registering constant layer: resnet_model/out_layer/MatMul/ReadVariableOp__273 for ONNX initializer: resnet_model/out_layer/MatMul/ReadVariableOp__273 builtin_op_importers.cpp:2120: GEMM: using FC layer instead of MM because all criteria were met. onnx2trt_utils.cpp:1815: Original shape: (_, 512), unsqueezing to: (_,_, _,_) ImporterContext.hpp:154: Registering layer: resnet_model/out_layer/MatMul for ONNX node: resnet_model/out_layer/MatMul onnx2trt_utils.cpp:1663: Original shape: (_, 2, 1, 1), squeezing to: (_, _) ImporterContext.hpp:120: Registering tensor: resnet_model/out_layer/MatMul:0 for ONNX tensor: resnet_model/out_layer/MatMul:0 ModelImporter.cpp:179: resnet_model/out_layer/MatMul [MatMul] outputs: [resnet_model/out_layer/MatMul:0 -> (-1, -1)], ModelImporter.cpp:103: Parsing node: Identity [Identity] ModelImporter.cpp:119: Searching for input: resnet_model/out_layer/MatMul:0 ModelImporter.cpp:125: Identity [Identity] inputs: [resnet_model/out_layer/MatMul:0 -> (-1, -1)], ImporterContext.hpp:154: Registering layer: Identity for ONNX node: Identity ImporterContext.hpp:120: Registering tensor: Identity_raw_output___3:0 for ONNX tensor: Identity_raw_output___3:0 ModelImporter.cpp:179: Identity [Identity] outputs: [Identity_raw_output___3:0 -> (-1, -1)], ModelImporter.cpp:103: Parsing node: Identity_graph_outputs_Identity__4 [Identity] ModelImporter.cpp:119: Searching for input: Identity_raw_output___3:0 ModelImporter.cpp:125: Identity_graph_outputs_Identity__4 [Identity] inputs: [Identity_raw_output___3:0 -> (-1, -1)], ImporterContext.hpp:154: Registering layer: Identity_graph_outputs_Identity__4 for ONNX node: Identity_graph_outputs_Identity__4 ImporterContext.hpp:120: Registering tensor: Identity:0_0 for ONNX tensor: Identity:0 ModelImporter.cpp:179: Identity_graph_outputs_Identity__4 [Identity] outputs: [Identity:0 -> (-1, -1)], ModelImporter.cpp:510: Marking Identity:0_0 as output: Identity:0
Up until the squeezing everything is fine, then the output dimesion si set to (-1,-1) instead of (-1, 2). When I access the dimension to allocate the inference buffers with network->getOutput(0)->getDimensions(); i get (-1,-1) instead of (-1, 2) which would be the correct one.
What version of TRT are yo using? Are you able to share the model?
Hi, I'm using the last version of trt. You can download the model from here: https://drive.google.com/file/d/1-gOVBgP93AlBhX11yfv7OJH9IKF1vECO/view?usp=sharing
I also encountered this problem when parsing yolov5 model. Has this issue been solved?
@kevinch-nv sorry for tagging you, do you have any good news?
@kevinch-nv I use the latest TensorRT 7.2.3 and can also reproduce this issue. How to get the correct dims of output from dynamic shape onnx? Do you have any suggestion?
same problem for convert resnet152 vgg19 models with TensorRT 7.2.3
[05/11/2021-20:05:33] [V] [TRT] ModelImporter.cpp:125: Gemm_16 [Gemm] inputs: [60 -> (-1, -1)], [2.fc.weight -> (1000, 2048)], [2.fc.bias -> (1000)],
[05/11/2021-20:05:33] [V] [TRT] builtin_op_importers.cpp:1021: GEMM: using FC layer instead of MM because all criteria were met.
[05/11/2021-20:05:33] [V] [TRT] onnx2trt_utils.cpp:1815: Original shape: (_, _), unsqueezing to: (_, _, _, _)
[05/11/2021-20:05:33] [V] [TRT] ImporterContext.hpp:154: Registering layer: Gemm_16 for ONNX node: Gemm_16
[05/11/2021-20:05:33] [V] [TRT] onnx2trt_utils.cpp:1663: Original shape: (_, 1000, 1, 1), squeezing to: (_, _)
[05/11/2021-20:05:33] [V] [TRT] ImporterContext.hpp:120: Registering tensor: output_0 for ONNX tensor: output
[05/11/2021-20:05:33] [V] [TRT] ModelImporter.cpp:179: Gemm_16 [Gemm] outputs: [output -> (-1, -1)],