[TensorRT] ERROR: add: kernel weights has count 800 but 25600 was expected

Here is the logger while using tensorrt to parse my uff model. I don’t know how to deal with this proble and this model can work on tensorflow.

[TensorRT] INFO: UFFParser: parsing input
[TensorRT] INFO: UFFParser: parsing Reshape/shape
[TensorRT] INFO: UFFParser: parsing Reshape
[TensorRT] INFO: UFFParser: parsing Variable
[TensorRT] INFO: UFFParser: parsing Conv2D
[TensorRT] INFO: UFFParser: parsing Variable_1
[TensorRT] INFO: UFFParser: parsing add
[TensorRT] INFO: UFFParser: parsing Relu
[TensorRT] INFO: UFFParser: parsing MaxPool
[TensorRT] INFO: UFFParser: Pooling: add Padding Layer to support asymmetric padding
[TensorRT] INFO: UFFParser: Pooling: Left: 0
[TensorRT] INFO: UFFParser: Pooling: Right: 1
[TensorRT] INFO: UFFParser: Pooling: Top: 0
[TensorRT] INFO: UFFParser: Pooling: Bottom: 0
[TensorRT] INFO: UFFParser: parsing Variable_2
[TensorRT] INFO: UFFParser: parsing Conv2D_1
[TensorRT] INFO: UFFParser: parsing Variable_3
[TensorRT] INFO: UFFParser: parsing add_1
[TensorRT] INFO: UFFParser: parsing Relu_1
[TensorRT] INFO: UFFParser: parsing MaxPool_1
[TensorRT] INFO: UFFParser: Pooling: add Padding Layer to support asymmetric padding
[TensorRT] INFO: UFFParser: Pooling: Left: 0
[TensorRT] INFO: UFFParser: Pooling: Right: 1
[TensorRT] INFO: UFFParser: Pooling: Top: 0
[TensorRT] INFO: UFFParser: Pooling: Bottom: 0
[TensorRT] INFO: UFFParser: parsing Reshape_1/shape
[TensorRT] INFO: UFFParser: parsing Reshape_1
[TensorRT] INFO: UFFParser: parsing Variable_4
[TensorRT] INFO: UFFParser: parsing MatMul
[TensorRT] INFO: UFFParser: parsing Variable_5
[TensorRT] INFO: UFFParser: parsing add_2
[TensorRT] INFO: UFFParser: parsing Relu_2
[TensorRT] INFO: UFFParser: parsing Variable_6
[TensorRT] INFO: UFFParser: parsing MatMul_1
[TensorRT] INFO: UFFParser: parsing Variable_7
[TensorRT] INFO: UFFParser: parsing add_3
[TensorRT] INFO: UFFParser: parsing output
[TensorRT] INFO: UFFParser: parsing MarkOutput_0
[TensorRT] ERROR: add: kernel weights has count 800 but 25600 was expected
[TensorRT] ERROR: add_2: kernel weights has count 1048576 but 131072 was expected
[TensorRT] ERROR: Failed to create engine
  File "/usr/local/lib/python2.7/dist-packages/tensorrt/utils/_utils.py", line 74, in uff_file_to_trt_engine
    assert(engine)
Traceback (most recent call last):
  File "./face_api.py", line 58, in <module>
    main()
  File "./face_api.py", line 53, in main
    trt.trt_test(args.cnn_model_path,args.video)
  File "/home/wly/trainspace/dlib/face_project5/lib/face_interface_trt.py", line 65, in trt_test
    egine = trt.utils.uff_file_to_trt_engine(G_LOGGER,uff_path,parser,MAX_BATCHSIZE,MAX_WORKSPACE,trt.infer.DataType.FLOAT)
  File "/usr/local/lib/python2.7/dist-packages/tensorrt/utils/_utils.py", line 82, in uff_file_to_trt_engine
    raise AssertionError('UFF parsing failed on line {} in statement {}'.format(line, text))
AssertionError: UFF parsing failed on line 74 in statement assert(engine)

You are configuring the model incorrectly.
Given that the model has to add asymmetric padding, my guess is that the input image size is not what the model was designed for.

Hi,

Could you share your model for us checking?

One possible reason is the reshape layer.
In TensorRT 3, reshape only apply on constant weights.
Tensor reshapes will automatically drop when importing UFF model to a TensorRT engine.

This may cause the output blob size different from the expectation.

Thanks.