onnx / onnx-tensorrt

ONNX-TensorRT: TensorRT backend for ONNX
Apache License 2.0
2.84k stars 538 forks source link

[8] Assertion failed: nbSpatialDims == kernelWeights.shape.nbDims - 2 #668

Open niuwagege opened 3 years ago

niuwagege commented 3 years ago

Description

converting onnx to tensorrt, occur [[8] Assertion failed: nbSpatialDims == kernelWeights.shape.nbDims - 2] image command: ./trtexec --onnx=test.onnx --saveEngine=test.trt --explicitBatch --workspace=4096

Environment

TensorRT Version: 7.2.1.6 ONNX-TensorRT Version / Branch: GPU Type: V100 Nvidia Driver Version: 440.64.00 CUDA Version: 10.2 CUDNN Version: 8.1.0.77 Operating System + Version: centos7 Python Version (if applicable): 3.6 TensorFlow + TF2ONNX Version (if applicable):tf:2.3.1 tf2onnx:1.7.2 PyTorch Version (if applicable): Baremetal or Container (if container which image + tag):

Relevant Files

[TensorRT] VERBOSE: ModelImporter.cpp:103: Parsing node: GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/concat [Concat] [TensorRT] VERBOSE: ModelImporter.cpp:119: Searching for input: GridAnchorGenerator/Meshgrid_2/Shape_1291:0 [TensorRT] VERBOSE: ModelImporter.cpp:119: Searching for input: const_fold_opt3618 [TensorRT] VERBOSE: ModelImporter.cpp:119: Searching for input: GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/Slice_1:0 [TensorRT] VERBOSE: ModelImporter.cpp:125: GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/concat [Concat] inputs: [GridAnchorGenerator/Meshgrid_2/Shape_1291:0 -> (2)], [const_fold_opt3618 -> (1)], [GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/Slice_1:0 -> (0)], [TensorRT] VERBOSE: ImporterContext.hpp:150: Registering constant layer: const_fold_opt__3618_8 for ONNX initializer: const_fold_opt__3618 [TensorRT] VERBOSE: ImporterContext.hpp:154: Registering layer: GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/concat for ONNX node: GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/concat [TensorRT] VERBOSE: ImporterContext.hpp:120: Registering tensor: GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/concat:0 for ONNX tensor: GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/concat:0 [TensorRT] VERBOSE: ModelImporter.cpp:179: GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/concat [Concat] outputs: [GridAnchorGenerator/Meshgrid_2/ExpandedShape_1/concat:0 -> (3)], [TensorRT] VERBOSE: ModelImporter.cpp:103: Parsing node: FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/conv1/Conv2D [Conv] [TensorRT] VERBOSE: ModelImporter.cpp:119: Searching for input: Preprocessor/sub:0 [TensorRT] VERBOSE: ModelImporter.cpp:119: Searching for input: FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/conv1/Conv2D_weights_fused_bn [TensorRT] VERBOSE: ModelImporter.cpp:119: Searching for input: FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/conv1/Conv2D_bias_fused_bn [TensorRT] VERBOSE: ModelImporter.cpp:125: FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/conv1/Conv2D [Conv] inputs: [Preprocessor/sub:0 -> (-1, 3)], [FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/conv1/Conv2D_weights_fused_bn -> (64, 3, 7, 7)], [FirstStageFeatureExtractor/resnet_v1_101/resnet_v1_101/conv1/Conv2D_bias_fused_bn -> (64)], [TensorRT] VERBOSE: builtin_op_importers.cpp:450: Convolution input dimensions: (-1, 3) In node -1 (importConv): UNSUPPORTED_NODE: Assertion failed: nbSpatialDims == kernelWeights.shape.nbDims - 2

Steps To Reproduce

kevinch-nv commented 3 years ago

It looks like your Conv data input is of shape (-1,3), which is incorrect. Are you able to share your ONNX model?

niuwagege commented 3 years ago

It looks like your Conv data input is of shape (-1,3), which is incorrect. Are you able to share your ONNX model?

Thanks for reply. The ONNX model is uploaded to Google Drive. https://drive.google.com/file/d/1YLdNxVAfTLEi7g61pL2b2HJQPmR0Q1i4/view?usp=sharing

004307ec commented 2 years ago

If the original ONNX model can run normally in OnnxRuntime, then it can be the result of a failed shape inference. You can check the Reshape Op in your ONNX graph. If the second argument of a Reshape Op is not from a single constant value tensor, but from other Op (like Concat), the inferred shape of the output of the Reshape Op can be all -1.