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

add ort nms op #803

Merged
merged 11 commits into from
Feb 4, 2021
Merged

add ort nms op #803

merged 11 commits into from
Feb 4, 2021

Conversation

tangyanf
Copy link
Contributor

add onnxruntime custom op: nms

@codecov
Copy link

codecov bot commented Jan 25, 2021

Codecov Report

Merging #803 (3c76e98) into master (00658e8) will increase coverage by 0.29%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #803      +/-   ##
==========================================
+ Coverage   61.94%   62.23%   +0.29%     
==========================================
  Files         144      144              
  Lines        8467     8506      +39     
  Branches     1520     1521       +1     
==========================================
+ Hits         5245     5294      +49     
+ Misses       2954     2947       -7     
+ Partials      268      265       -3     
Flag Coverage Δ
unittests 62.23% <0.00%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmcv/ops/nms.py 34.43% <0.00%> (ø)
mmcv/image/io.py 90.75% <0.00%> (+1.77%) ⬆️
mmcv/runner/checkpoint.py 66.22% <0.00%> (+7.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00658e8...3c76e98. Read the comment docs.

@hellock
Copy link
Member

hellock commented Jan 25, 2021

@grimoire Would you help review this PR?

@grimoire
Copy link
Member

@hellock Sure, I will do it.

@grimoire
Copy link
Member

Hi @tangyanf, thanks for your contribution!
As long as onnxruntime already has an official nms implementation, I think we might not have to create custom one.
The diff between pytorch and onnxruntime is caused by offset, use the code below could fix this:

        if torch.onnx.is_in_onnx_export() and offset == 1:
            # ONNX only support offset == 1
            boxes[:, -2:] += 1
        inds = NMSop.apply(boxes, scores, iou_threshold, offset)
        if torch.onnx.is_in_onnx_export() and offset == 1:
            # ONNX only support offset == 1
            boxes[:, -2:] -= 1

@tangyanf tangyanf closed this Jan 27, 2021
@tangyanf tangyanf reopened this Jan 27, 2021
mmcv/ops/nms.py Outdated Show resolved Hide resolved
tests/test_ops/test_onnx.py Outdated Show resolved Hide resolved
@hellock hellock merged commit be2616a into open-mmlab:master Feb 4, 2021
hellock pushed a commit that referenced this pull request Feb 5, 2021
* add header to std::iota

* fix lint

* fix lint for cpp
RunningLeon added a commit to grimoire/mmcv that referenced this pull request Feb 5, 2021
ZwwWayne pushed a commit that referenced this pull request Feb 23, 2021
* start trt plugin prototype

* Add test module, modify roialign convertor

* finish roi_align trt plugin

* fix conflict of RoiAlign and MMCVRoiAlign

* fix for lint

* fix test tensorrt module

* test_tensorrt move import to test func

* add except error type

* add tensorrt to setup.cfg

* code format with yapf

* fix for clang-format

* move tensorrt_utils to mmcv/tensorrt, add comments, better test module

* fix line endings, docformatter

* isort init, remove trailing whitespace

* add except type

* fix setup.py

* put import extension inside trt setup

* change c++ guard, update pytest script, better setup, etc

* sort import with isort

* sort import with isort

* move init of plugin lib to init_plugins.py

* add scatternd, nms plugin (WIP)

* fix bugs of trt_nms

* add trt nms test module

* fix bugs of scatternd

* code optimize, add comment about nms kernel

* fix transform_if bug of trt_nms_kernel

* fix struct name

* default nms offset=0, fix bugs of batched input

* format with clang-format

* onnx preprocess

* much better nms implementation, no need to transfer memory between host and device

* update preprocess_onnx

* parse constant tensor from initializer in preprocess_onnx

* update nms

* remove unnecessary codes

* workspace aligned address

* format trt_plugin_helper.hpp

* fix index memory bugs

* set alignment to 16 by default

* fix lint

* fix nms offset

* fix bugs of preprocess onnx

* update test for nms

* tensorrt only accept int32, not int64

* update nms comments

* fix indexing for scores in nms

* update trt temp

* make trt-nms compatiable to #803

* fix lint

* add docstring to trt_nms_kernel.cuda, add description to preprocess_onnx

* add comment to score indexing

* fix bugs of max output boxes

Co-authored-by: maningsheng <maningsheng@sensetime.com>
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

Successfully merging this pull request may close these issues.

3 participants