Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EfficientNMS plugin doesn't support fp16 #1758

Closed
lucasjinreal opened this issue Jan 26, 2022 · 5 comments
Closed

EfficientNMS plugin doesn't support fp16 #1758

lucasjinreal opened this issue Jan 26, 2022 · 5 comments

Comments

@lucasjinreal
Copy link

I have an onnx model, injected EfficientNMS plugin using graph-surgon, the inference result like this in fp16:

(array([38], dtype=int32), array([[448.      , 310.75    , 557.5     , 413.25    ],
       [324.25    , 308.      , 346.25    , 326.5     ],
       [193.25    , 302.5     , 225.      , 327.5     ],
       [371.5     , 288.25    , 381.      , 301.75    ],
       [448.      , 310.      , 559.5     , 414.      ],
       [329.75    , 308.75    , 350.75    , 328.25    ],
       [397.75    , 306.      , 454.25    , 363.      ],
       [368.      , 311.      , 387.      , 342.5     ],
       [422.25    , 321.      , 464.75    , 378.5     ],
       [379.5     , 309.5     , 410.      , 351.5     ],
       [541.      , 305.25    , 640.      , 478.25    ],
       [306.5     , 267.25    , 310.      , 276.25    ],
       [225.25    , 305.5     , 247.75    , 324.5     ],
       [348.      , 309.25    , 369.      , 334.25    ],
       [258.25    , 306.      , 274.25    , 324.      ],
       [372.5     , 310.25    , 403.5     , 345.75    ],
       [194.875   , 303.25    , 224.625   , 326.25    ],
       [255.375   , 312.25    , 274.25    , 327.25    ],
       [256.5     , 309.75    , 274.5     , 326.75    ],
       [360.5     , 311.25    , 383.      , 340.25    ],
       [399.5     , 305.5     , 454.5     , 363.5     ],
       [541.      , 303.25    , 640.      , 482.75    ],
       [421.      , 320.5     , 466.5     , 377.      ],
       [446.75    , 309.5     , 558.5     , 412.5     ],
       [354.75    , 310.25    , 371.25    , 334.25    ],
       [321.      , 307.5     , 334.5     , 323.      ],
       [330.5     , 308.5     , 347.5     , 327.5     ],
       [255.5     , 307.      , 274.5     , 326.5     ],
       [378.75    , 314.25    , 406.25    , 350.25    ],
       [ 12.296875, 299.5     ,  22.390625, 324.      ],
       [194.125   , 303.25    , 223.875   , 326.25    ],
       [275.75    , 261.25    , 283.25    , 275.75    ],
       [354.75    , 311.      , 372.25    , 336.5     ],
       [343.75    , 310.      , 360.75    , 330.5     ],
       [346.5     , 310.      , 369.      , 334.      ],
       [364.75    , 310.      , 394.75    , 344.      ],
       [447.75    , 310.75    , 557.5     , 413.25    ],
       [371.75    , 310.25    , 404.25    , 345.75    ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ],
       [  0.      ,   0.      ,   0.      ,   0.      ]], dtype=float32), array([-0.7505, -0.505 , -0.7524, -0.754 , -0.511 , -0.511 , -0.5156,
       -0.5215, -0.5225, -0.525 , -0.5254, -0.765 , -0.7656, -0.538 ,
       -0.7695, -0.7715, -0.546 , -0.786 , -0.574 , -0.5938, -0.1953,
       -0.21  , -0.2183, -0.2261, -0.619 , -0.6323, -0.2988, -0.3066,
       -0.3384, -0.6694, -0.3599, -0.6963, -0.4214, -0.7227, -0.4497,
       -0.742 , -0.746 , -0.746 ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,  0.    ,
        0.    ,  0.    ], dtype=float16), array([ 7,  2,  2,  9,  2,  2,  2,  2,  2,  2,  2,  9,  2,  2,  2,  2,  2,
        2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2, 12,  2,  9,  2,  2,
        2,  2,  7,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],
      dtype=int32))

the boxes and labels are normal, but scores are wrong, it was negative values.

using fp32 without this problem.

My env:

  • TensorRT 8.2
  • CUDA11.5
  • 2060
@wraveane
Copy link
Contributor

This seems to be related to an optimization that's in place for sorting in fp16 where it wrongly assumes all scores are within [0-1] range. If your scores are outside of this range, i.e. negative values, it can give wrong results. There will be a fix for this soon.

@lucasjinreal
Copy link
Author

@wraveane Does it means must wait until next tensorrt version release? that would be a long time.

@wraveane
Copy link
Contributor

wraveane commented Feb 5, 2022

@jinfagang An update to the EfficientNMS plugin has been posted yesterday which, among other things, fixes this FP16 problem on non-sigmoid activated input scores.
Yes, the fix should be available on the next TensorRT release, but until then, you can also build this repository from source now, and replace the libnvinfer_plugin.so.8.x.x library installed by TensorRT with the one built from this repository.
Please let me know if that resolves the issue you were having.

@lucasjinreal
Copy link
Author

@wraveane thanks.

@liuchangf
Copy link

you can just +1 for each score in older version of tensorRT , it will very close to original detection score

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants