Assertion failed: cond.is_weights() && cond.weights().count() == 1 && "If condition must be a initializer!"

Hi Nvidia Team,

I am converting the model from ONNX to TRT. But during the Conversion, I am getting an error as Assertion failed: cond.is_weights() && cond.weights().count() == 1 && “If condition must be a initializer!”.

I am attaching the ONNX model below:

Command: ./trtexec --onnx=/home/darshan/slow_fast.onnx --shapes=input1:1x3x8x256x455,input2:1x3x32x256x455 --plugins=/home/darshan/Einsum_op_dynamic.so

Verbose of the trtexec:

[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Relu_604 [Relu] outputs: [2174 -> (1, 64, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Conv_605 [Conv]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2174
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2873
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2874
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Conv_605 [Conv] inputs: [2174 -> (1, 64, 32, 16, 29)], [2873 -> (64, 64, 1, 3, 3)], [2874 -> (64)], 
[02/22/2021-17:44:29] [V] [TRT] builtin_op_importers.cpp:450: Convolution input dimensions: (1, 64, 32, 16, 29)
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Conv_605 for ONNX node: Conv_605
[02/22/2021-17:44:29] [V] [TRT] builtin_op_importers.cpp:533: Using kernel: (1, 3, 3), strides: (1, 1, 1), prepadding: (0, 2, 2), postpadding: (0, 2, 2), dilations: (1, 2, 2), numOutputs: 64
[02/22/2021-17:44:29] [V] [TRT] builtin_op_importers.cpp:534: Convolution output dimensions: (1, 64, 32, 16, 29)
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2872 for ONNX tensor: 2872
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Conv_605 [Conv] outputs: [2872 -> (1, 64, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Relu_606 [Relu]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2872
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Relu_606 [Relu] inputs: [2872 -> (1, 64, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Relu_606 for ONNX node: Relu_606
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2177 for ONNX tensor: 2177
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Relu_606 [Relu] outputs: [2177 -> (1, 64, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Conv_607 [Conv]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2177
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2876
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2877
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Conv_607 [Conv] inputs: [2177 -> (1, 64, 32, 16, 29)], [2876 -> (256, 64, 1, 1, 1)], [2877 -> (256)], 
[02/22/2021-17:44:29] [V] [TRT] builtin_op_importers.cpp:450: Convolution input dimensions: (1, 64, 32, 16, 29)
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Conv_607 for ONNX node: Conv_607
[02/22/2021-17:44:29] [V] [TRT] builtin_op_importers.cpp:533: Using kernel: (1, 1, 1), strides: (1, 1, 1), prepadding: (0, 0, 0), postpadding: (0, 0, 0), dilations: (1, 1, 1), numOutputs: 256
[02/22/2021-17:44:29] [V] [TRT] builtin_op_importers.cpp:534: Convolution output dimensions: (1, 256, 32, 16, 29)
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2875 for ONNX tensor: 2875
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Conv_607 [Conv] outputs: [2875 -> (1, 256, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Add_608 [Add]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2171
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2875
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Add_608 [Add] inputs: [2171 -> (1, 256, 32, 16, 29)], [2875 -> (1, 256, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Add_608 for ONNX node: Add_608
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2180 for ONNX tensor: 2180
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Add_608 [Add] outputs: [2180 -> (1, 256, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Relu_609 [Relu]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2180
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Relu_609 [Relu] inputs: [2180 -> (1, 256, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Relu_609 for ONNX node: Relu_609
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2181 for ONNX tensor: 2181
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Relu_609 [Relu] outputs: [2181 -> (1, 256, 32, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Constant_610 [Constant]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Constant_610 [Constant] inputs: 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Constant_610 [Constant] outputs: [2182 -> (10)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Pad_611 [Pad]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2149
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2182
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Pad_611 [Pad] inputs: [2149 -> (1, 2048, 8, 16, 29)], [2182 -> (10)], 
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Pad_611 for ONNX node: Pad_611
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2183 for ONNX tensor: 2183
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Pad_611 [Pad] outputs: [2183 -> (1, 2048, 8, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: AveragePool_612 [AveragePool]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2183
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: AveragePool_612 [AveragePool] inputs: [2183 -> (1, 2048, 8, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: AveragePool_612 for ONNX node: AveragePool_612
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2184 for ONNX tensor: 2184
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: AveragePool_612 [AveragePool] outputs: [2184 -> (1, 2048, 1, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Constant_613 [Constant]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Constant_613 [Constant] inputs: 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Constant_613 [Constant] outputs: [2185 -> (1)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Shape_614 [Shape]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2184
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Shape_614 [Shape] inputs: [2184 -> (1, 2048, 1, 16, 29)], 
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Shape_614 for ONNX node: Shape_614
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2186 for ONNX tensor: 2186
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Shape_614 [Shape] outputs: [2186 -> (5)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Gather_615 [Gather]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2186
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2185
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Gather_615 [Gather] inputs: [2186 -> (5)], [2185 -> (1)], 
[02/22/2021-17:44:29] [V] [TRT] builtin_op_importers.cpp:986: Using Gather axis: 0
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Gather_615 for ONNX node: Gather_615
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2187 for ONNX tensor: 2187
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Gather_615 [Gather] outputs: [2187 -> (1)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Constant_616 [Constant]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Constant_616 [Constant] inputs: 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Constant_616 [Constant] outputs: [2188 -> (1)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: Equal_617 [Equal]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2187
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2188
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: Equal_617 [Equal] inputs: [2187 -> (1)], [2188 -> (1)], 
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:141: Registering layer: Equal_617 for ONNX node: Equal_617
[02/22/2021-17:44:29] [V] [TRT] ImporterContext.hpp:116: Registering tensor: 2189 for ONNX tensor: 2189
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:179: Equal_617 [Equal] outputs: [2189 -> (1)], 
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:103: Parsing node: If_618 [If]
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:119: Searching for input: 2189
[02/22/2021-17:44:29] [V] [TRT] ModelImporter.cpp:125: If_618 [If] inputs: [2189 -> (1)], 
ERROR: builtin_op_importers.cpp:1554 In function importIf:
[8] Assertion failed: cond.is_weights() && cond.weights().count() == 1 && "If condition must be a initializer!"
[02/22/2021-17:44:29] [E] Failed to parse onnx file
[02/22/2021-17:44:29] [E] Parsing model failed
[02/22/2021-17:44:29] [E] Engine creation failed
[02/22/2021-17:44:29] [E] Engine set up failed
&&&& FAILED TensorRT.trtexec # ./trtexec --onnx=/home/darshan/slow_fast.onnx --shapes=input1:1x3x8x256x455,input2:1x3x32x256x455 --plugins=/home/darshan/RoI_Align_dynamic.so --plugins=/home/darshan/Einsum_op_dynamic.so --verbose

Environment:
CUDA version: 10.2
TRT version: 7.1.3
OS: Ubuntu 18.04
GPU: RTX 2060

ONNX Information:
ONNX IR version: 0.0.6
Opset version: 12
Producer name: pytorch
Producer version: 1.7
Domain:
Model version: 0

Thanks

Looking forward to the reply.

Hi @darshancganji12,

Hope this will help you.

Thank you.

Exporting with torch version 1.6 solved this Issue(earlier was 1.7).

1 Like