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

[Refactor] Refactor the directory of csrc #1206

Merged
merged 21 commits into from
Aug 10, 2021

Conversation

zhouzaida
Copy link
Collaborator

@zhouzaida zhouzaida commented Jul 19, 2021

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Refactor the directory mmcv/ops/csrc to flexibly support more backends.

Follow commands have been successfully tested

MMCV_WITH_OPS=1 pip install -e .
pytest tests
MMCV_WITH_OPS=1 MMCV_WITH_ORT=1 pip install -e .
pytest tests
MMCV_WITH_OPS=1 MMCV_WITH_TRT=1 pip install -e .
pytest tests

Modification

  • mmcv/ops/csrc and setup.py are modified
  • mmcv/ops/csrc/README.md is added for explaining the structure of csrc and how to add new ops
  • docs/compatibility.md and docs_zh_CN/compatibility.md are added for recording compatibility
.
├── common
│   ├── box_iou_rotated_utils.hpp
│   ├── parrots_cpp_helper.hpp
│   ├── parrots_cuda_helper.hpp
│   ├── pytorch_cpp_helper.hpp
│   └── pytorch_cuda_helper.hpp
│   ├── cuda
│   │   ├── bbox_overlaps_cuda_kernel.cuh
│   │   ├── border_align_cuda_kernel.cuh
│   │   ├── box_iou_rotated_cuda.cuh
│   │   ├── carafe_cuda_kernel.cuh
│   │   ├── carafe_naive_cuda_kernel.cuh
│   │   ├── cc_attention_cuda_kernel.cuh
│   │   ├── common_cuda_helper.hpp
│   │   ├── deform_conv_cuda_kernel.cuh
│   │   ├── deform_roi_pool_cuda_kernel.cuh
│   │   ├── masked_conv2d_cuda_kernel.cuh
│   │   ├── modulated_deform_conv_cuda_kernel.cuh
│   │   ├── ms_deform_attn_cuda_kernel.cuh
│   │   ├── nms_cuda_kernel.cuh
│   │   ├── nms_rotated_cuda.cuh
│   │   ├── parrots_cudawarpfunction.cuh
│   │   ├── psamask_cuda_kernel.cuh
│   │   ├── roi_align_cuda_kernel.cuh
│   │   ├── roi_align_rotated_cuda_kernel.cuh
│   │   ├── roi_pool_cuda_kernel.cuh
│   │   ├── sigmoid_focal_loss_cuda_kernel.cuh
│   │   ├── softmax_focal_loss_cuda_kernel.cuh
│   │   ├── sync_bn_cuda_kernel.cuh
│   │   └── tin_shift_cuda_kernel.cuh
├── onnxruntime
│   ├── corner_pool.h
│   ├── grid_sample.h
│   ├── nms.h
│   ├── onnxruntime_register.h
│   ├── onnxruntime_session_options_config_keys.h
│   ├── ort_mmcv_utils.h
│   ├── reduce_ops.h
│   ├── roi_align.h
│   ├── roi_align_rotated.h
│   └── soft_nms.h
│   ├── cpu
│   │   ├── corner_pool.cpp
│   │   ├── gridSample.cpp
│   │   ├── nms.cpp
│   │   ├── onnxruntime_register.cpp
│   │   ├── reduce_ops.cpp
│   │   ├── roi_align.cpp
│   │   ├── roi_align_rotated.cpp
│   │   └── soft_nms.cpp
├── parrots
│   ├── bbox_overlaps.cpp
│   ├── bbox_overlaps_parrots.cpp
│   ├── bbox_overlaps_pytorch.h
│   ├── border_align.cpp
│   ├── border_align_parrots.cpp
│   ├── border_align_pytorch.h
│   ├── box_iou_rotated.cpp
│   ├── box_iou_rotated_cpu.cpp
│   ├── box_iou_rotated_parrots.cpp
│   ├── box_iou_rotated_pytorch.h
│   ├── carafe.cpp
│   ├── carafe_naive.cpp
│   ├── carafe_naive_parrots.cpp
│   ├── carafe_naive_pytorch.h
│   ├── carafe_parrots.cpp
│   ├── carafe_pytorch.h
│   ├── cc_attention.cpp
│   ├── cc_attention_parrots.cpp
│   ├── cc_attention_pytorch.h
│   ├── corner_pool.cpp
│   ├── corner_pool_parrots.cpp
│   ├── corner_pool_pytorch.h
│   ├── deform_conv.cpp
│   ├── deform_conv_parrots.cpp
│   ├── deform_conv_pytorch.h
│   ├── deform_roi_pool.cpp
│   ├── deform_roi_pool_parrots.cpp
│   ├── deform_roi_pool_pytorch.h
│   ├── focal_loss.cpp
│   ├── focal_loss_parrots.cpp
│   ├── focal_loss_pytorch.h
│   ├── fused_bias_leakyrelu.cpp
│   ├── fused_bias_parrots.cpp
│   ├── masked_conv2d.cpp
│   ├── masked_conv2d_parrots.cpp
│   ├── masked_conv2d_pytorch.h
│   ├── modulated_deform_conv.cpp
│   ├── modulated_deform_conv_parrots.cpp
│   ├── modulated_deform_conv_pytorch.h
│   ├── ms_deform_attn.cpp
│   ├── ms_deform_attn_parrots.cpp
│   ├── nms.cpp
│   ├── nms_parrots.cpp
│   ├── nms_pytorch.h
│   ├── nms_rotated.cpp
│   ├── nms_rotated_cpu.cpp
│   ├── psamask.cpp
│   ├── psamask_parrots.cpp
│   ├── psamask_pytorch.h
│   ├── roi_align.cpp
│   ├── roi_align_cpu.cpp
│   ├── roi_align_parrots.cpp
│   ├── roi_align_pytorch.h
│   ├── roi_align_rotated.cpp
│   ├── roi_align_rotated_cpu.cpp
│   ├── roi_align_rotated_parrots.cpp
│   ├── roi_align_rotated_pytorch.h
│   ├── roi_pool.cpp
│   ├── roi_pool_parrots.cpp
│   ├── roi_pool_pytorch.h
│   ├── sync_bn.cpp
│   ├── sync_bn_parrots.cpp
│   ├── sync_bn_pytorch.h
│   ├── tin_shift.cpp
│   ├── tin_shift_parrots.cpp
│   ├── tin_shift_pytorch.h
│   ├── upfirdn2d.cpp
│   └── upfirdn2d_parrots.cpp
├── pytorch
│   ├── bbox_overlaps.cpp
│   ├── border_align.cpp
│   ├── box_iou_rotated.cpp
│   ├── box_iou_rotated_cpu.cpp
│   ├── carafe.cpp
│   ├── carafe_naive.cpp
│   ├── cc_attention.cpp
│   ├── contour_expand.cpp
│   ├── corner_pool.cpp
│   ├── deform_conv.cpp
│   ├── deform_roi_pool.cpp
│   ├── focal_loss.cpp
│   ├── fused_bias_leakyrelu.cpp
│   ├── info.cpp
│   ├── masked_conv2d.cpp
│   ├── modulated_deform_conv.cpp
│   ├── ms_deform_attn.cpp
│   ├── nms.cpp
│   ├── nms_rotated.cpp
│   ├── nms_rotated_cpu.cpp
│   ├── pixel_group.cpp
│   ├── psamask.cpp
│   ├── pybind.cpp
│   ├── roi_align.cpp
│   ├── roi_align_cpu.cpp
│   ├── roi_align_rotated.cpp
│   ├── roi_align_rotated_cpu.cpp
│   ├── roi_pool.cpp
│   ├── sync_bn.cpp
│   ├── tin_shift.cpp
│   └── upfirdn2d.cpp
│   ├── cuda
│   │   ├── bbox_overlaps_cuda.cu
│   │   ├── border_align_cuda.cu
│   │   ├── box_iou_rotated_cuda.cu
│   │   ├── carafe_cuda.cu
│   │   ├── carafe_naive_cuda.cu
│   │   ├── cc_attention_cuda.cu
│   │   ├── deform_conv_cuda.cu
│   │   ├── deform_roi_pool_cuda.cu
│   │   ├── focal_loss_cuda.cu
│   │   ├── fused_bias_leakyrelu_cuda.cu
│   │   ├── masked_conv2d_cuda.cu
│   │   ├── modulated_deform_conv_cuda.cu
│   │   ├── ms_deform_attn_cuda.cu
│   │   ├── nms_cuda.cu
│   │   ├── nms_rotated_cuda.cu
│   │   ├── psamask_cuda.cu
│   │   ├── roi_align_cuda.cu
│   │   ├── roi_align_rotated_cuda.cu
│   │   ├── roi_pool_cuda.cu
│   │   ├── sync_bn_cuda.cu
│   │   ├── tin_shift_cuda.cu
│   │   └── upfirdn2d_kernel.cu
└── tensorrt
    ├── plugins
    │   ├── trt_corner_pool.cpp
    │   ├── trt_corner_pool_kernel.cu
    │   ├── trt_cuda_helper.cu
    │   ├── trt_cummaxmin.cpp
    │   ├── trt_cummaxmin_kernel.cu
    │   ├── trt_deform_conv.cpp
    │   ├── trt_deform_conv_kernel.cu
    │   ├── trt_grid_sampler.cpp
    │   ├── trt_grid_sampler_kernel.cu
    │   ├── trt_instance_norm.cpp
    │   ├── trt_modulated_deform_conv.cpp
    │   ├── trt_modulated_deform_conv_kernel.cu
    │   ├── trt_nms.cpp
    │   ├── trt_nms_kernel.cu
    │   ├── trt_plugin.cpp
    │   ├── trt_roi_align.cpp
    │   ├── trt_roi_align_kernel.cu
    │   ├── trt_scatternd.cpp
    │   └── trt_scatternd_kernel.cu
    ├── trt_corner_pool.hpp
    ├── trt_cuda_helper.cuh
    ├── trt_cummaxmin.hpp
    ├── trt_deform_conv.hpp
    ├── trt_grid_sampler.hpp
    ├── trt_instance_norm.hpp
    ├── trt_modulated_deform_conv.hpp
    ├── trt_nms.hpp
    ├── trt_plugin_helper.hpp
    ├── trt_plugin.hpp
    ├── trt_roi_align.hpp
    ├── trt_scatternd.hpp
    └── trt_serialize.hpp

9 directories, 200 files

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@zhouzaida zhouzaida requested a review from grimoire July 19, 2021 07:14
@zhouzaida zhouzaida requested a review from ZwwWayne July 19, 2021 07:28
@codecov
Copy link

codecov bot commented Jul 19, 2021

Codecov Report

Merging #1206 (84c02a0) into master (94a677d) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1206   +/-   ##
=======================================
  Coverage   68.28%   68.28%           
=======================================
  Files         160      160           
  Lines       10603    10603           
  Branches     1937     1937           
=======================================
  Hits         7240     7240           
  Misses       2979     2979           
  Partials      384      384           
Flag Coverage Δ
unittests 68.28% <ø> (ø)

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


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 94a677d...84c02a0. Read the comment docs.

@zhouzaida zhouzaida requested a review from hellock July 19, 2021 08:46
@zhouzaida zhouzaida changed the title [WIP] Refactor the directory of csrc [Refactor] Refactor the directory of csrc Jul 20, 2021
@ZwwWayne
Copy link
Collaborator

I suggest we start to maintain compatibility documentation as in https://mmdetection.readthedocs.io/en/latest/compatibility.html to record these refactoring changes. Though they do not affect the usage in API.

@zhouzaida
Copy link
Collaborator Author

I suggest we start to maintain compatibility documentation as in https://mmdetection.readthedocs.io/en/latest/compatibility.html to record these refactoring changes. Though they do not affect the usage in API.

OK

Copy link
Member

@grimoire grimoire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename HIP_DIFF to MMCV_WITH_HIP, just like other mmcv flag?

MANIFEST.in Outdated Show resolved Hide resolved
@ZwwWayne ZwwWayne requested a review from grimoire July 23, 2021 13:09
docs/compatibility.md Show resolved Hide resolved
mmcv/ops/csrc/README.md Outdated Show resolved Hide resolved
@zhouzaida zhouzaida mentioned this pull request Jul 27, 2021
18 tasks
@ZwwWayne ZwwWayne merged commit dfb48c8 into open-mmlab:master Aug 10, 2021
@zhouzaida zhouzaida deleted the refactor-csrc branch August 10, 2021 07:57
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