├── .dev_scripts
└── check_installation.py
├── .dockerignore
├── .github
├── ISSUE_TEMPLATE
│ ├── 1-bug-report.yml
│ ├── 2-feature_request.yml
│ ├── 3-documentation.yml
│ └── config.yml
├── pull_request_template.md
└── workflows
│ ├── build_macos_wheel.yml
│ ├── lint.yml
│ ├── merge_stage_test.yml
│ ├── pr_stage_test.yml
│ └── publish-to-pypi.yml
├── .gitignore
├── .pre-commit-config-zh-cn.yaml
├── .pre-commit-config.yaml
├── .readthedocs.yml
├── CITATION.cff
├── CONTRIBUTING.md
├── CONTRIBUTING_zh-CN.md
├── LICENSE
├── LICENSES.md
├── MANIFEST.in
├── README.md
├── README_zh-CN.md
├── TERMINOLOGY.md
├── docker
├── README.md
├── dev
│ └── Dockerfile
└── release
│ └── Dockerfile
├── docs
├── en
│ ├── Makefile
│ ├── _static
│ │ ├── community
│ │ │ ├── 1.png
│ │ │ ├── 2.png
│ │ │ └── 3.png
│ │ ├── css
│ │ │ └── readthedocs.css
│ │ ├── flow_img2toimg1.png
│ │ ├── flow_raw_images.png
│ │ ├── flow_visualization.png
│ │ ├── flow_warp.png
│ │ ├── flow_warp_diff.png
│ │ ├── image
│ │ │ └── mmcv-logo.png
│ │ ├── parallel_progress.gif
│ │ ├── parallel_progress.png
│ │ ├── progress.gif
│ │ ├── progress.png
│ │ └── version.json
│ ├── _templates
│ │ └── classtemplate.rst
│ ├── api
│ │ ├── arraymisc.rst
│ │ ├── cnn.rst
│ │ ├── image.rst
│ │ ├── ops.rst
│ │ ├── transforms.rst
│ │ ├── utils.rst
│ │ ├── video.rst
│ │ └── visualization.rst
│ ├── community
│ │ ├── contributing.md
│ │ └── pr.md
│ ├── compatibility.md
│ ├── conf.py
│ ├── deployment
│ │ └── mmcv_ops_definition.md
│ ├── docutils.conf
│ ├── faq.md
│ ├── get_started
│ │ ├── api_reference.md
│ │ ├── build.md
│ │ ├── installation.md
│ │ ├── introduction.md
│ │ └── previous_versions.md
│ ├── index.rst
│ ├── make.bat
│ ├── mmcv-logo.png
│ ├── switch_language.md
│ └── understand_mmcv
│ │ ├── cnn.md
│ │ ├── data_process.md
│ │ ├── data_transform.md
│ │ ├── ops.md
│ │ └── visualization.md
└── zh_cn
│ ├── Makefile
│ ├── _static
│ ├── css
│ │ └── readthedocs.css
│ ├── image
│ │ └── mmcv-logo.png
│ └── version.json
│ ├── _templates
│ └── classtemplate.rst
│ ├── api
│ ├── arraymisc.rst
│ ├── cnn.rst
│ ├── image.rst
│ ├── ops.rst
│ ├── transforms.rst
│ ├── utils.rst
│ ├── video.rst
│ └── visualization.rst
│ ├── community
│ ├── code_style.md
│ ├── contributing.md
│ └── pr.md
│ ├── compatibility.md
│ ├── conf.py
│ ├── docutils.conf
│ ├── faq.md
│ ├── get_started
│ ├── api_reference.md
│ ├── article.md
│ ├── build.md
│ ├── installation.md
│ ├── introduction.md
│ └── previous_versions.md
│ ├── index.rst
│ ├── make.bat
│ ├── mmcv-logo.png
│ ├── switch_language.md
│ └── understand_mmcv
│ ├── cnn.md
│ ├── data_process.md
│ ├── data_transform.md
│ ├── ops.md
│ └── visualization.md
├── mmcv
├── __init__.py
├── arraymisc
│ ├── __init__.py
│ └── quantization.py
├── cnn
│ ├── __init__.py
│ ├── alexnet.py
│ ├── bricks
│ │ ├── __init__.py
│ │ ├── activation.py
│ │ ├── context_block.py
│ │ ├── conv.py
│ │ ├── conv2d_adaptive_padding.py
│ │ ├── conv_module.py
│ │ ├── conv_ws.py
│ │ ├── depthwise_separable_conv_module.py
│ │ ├── drop.py
│ │ ├── generalized_attention.py
│ │ ├── hsigmoid.py
│ │ ├── hswish.py
│ │ ├── non_local.py
│ │ ├── norm.py
│ │ ├── padding.py
│ │ ├── plugin.py
│ │ ├── scale.py
│ │ ├── swish.py
│ │ ├── transformer.py
│ │ ├── upsample.py
│ │ └── wrappers.py
│ ├── resnet.py
│ ├── rfsearch
│ │ ├── __init__.py
│ │ ├── operator.py
│ │ ├── search.py
│ │ └── utils.py
│ ├── utils
│ │ ├── __init__.py
│ │ ├── flops_counter.py
│ │ └── fuse_conv_bn.py
│ └── vgg.py
├── image
│ ├── __init__.py
│ ├── colorspace.py
│ ├── geometric.py
│ ├── io.py
│ ├── misc.py
│ └── photometric.py
├── ops
│ ├── __init__.py
│ ├── active_rotated_filter.py
│ ├── assign_score_withk.py
│ ├── ball_query.py
│ ├── bbox.py
│ ├── bezier_align.py
│ ├── bias_act.py
│ ├── border_align.py
│ ├── box_iou_quadri.py
│ ├── box_iou_rotated.py
│ ├── carafe.py
│ ├── cc_attention.py
│ ├── chamfer_distance.py
│ ├── contour_expand.py
│ ├── conv2d_gradfix.py
│ ├── convex_iou.py
│ ├── corner_pool.py
│ ├── correlation.py
│ ├── csrc
│ │ ├── README.md
│ │ ├── common
│ │ │ ├── box_iou_rotated_utils.hpp
│ │ │ ├── cuda
│ │ │ │ ├── active_rotated_filter_cuda_kernel.cuh
│ │ │ │ ├── assign_score_withk_cuda_kernel.cuh
│ │ │ │ ├── ball_query_cuda_kernel.cuh
│ │ │ │ ├── bbox_overlaps_cuda_kernel.cuh
│ │ │ │ ├── bezier_align_cuda_kernel.cuh
│ │ │ │ ├── border_align_cuda_kernel.cuh
│ │ │ │ ├── box_iou_quadri_cuda.cuh
│ │ │ │ ├── box_iou_rotated_cuda.cuh
│ │ │ │ ├── carafe_cuda_kernel.cuh
│ │ │ │ ├── carafe_naive_cuda_kernel.cuh
│ │ │ │ ├── chamfer_distance_cuda_kernel.cuh
│ │ │ │ ├── common_cuda_helper.hpp
│ │ │ │ ├── convex_iou_cuda_kernel.cuh
│ │ │ │ ├── correlation_cuda.cuh
│ │ │ │ ├── deform_conv_cuda_kernel.cuh
│ │ │ │ ├── deform_roi_pool_cuda_kernel.cuh
│ │ │ │ ├── diff_iou_rotated_cuda_kernel.cuh
│ │ │ │ ├── furthest_point_sample_cuda_kernel.cuh
│ │ │ │ ├── gather_points_cuda_kernel.cuh
│ │ │ │ ├── group_points_cuda_kernel.cuh
│ │ │ │ ├── iou3d_cuda_kernel.cuh
│ │ │ │ ├── knn_cuda_kernel.cuh
│ │ │ │ ├── masked_conv2d_cuda_kernel.cuh
│ │ │ │ ├── min_area_polygons_cuda.cuh
│ │ │ │ ├── modulated_deform_conv_cuda_kernel.cuh
│ │ │ │ ├── ms_deform_attn_cuda_kernel.cuh
│ │ │ │ ├── nms_cuda_kernel.cuh
│ │ │ │ ├── nms_quadri_cuda.cuh
│ │ │ │ ├── nms_rotated_cuda.cuh
│ │ │ │ ├── parrots_cudawarpfunction.cuh
│ │ │ │ ├── points_in_boxes_cuda_kernel.cuh
│ │ │ │ ├── points_in_polygons_cuda_kernel.cuh
│ │ │ │ ├── prroi_pool_cuda_kernel.cuh
│ │ │ │ ├── psamask_cuda_kernel.cuh
│ │ │ │ ├── riroi_align_rotated_cuda_kernel.cuh
│ │ │ │ ├── roi_align_cuda_kernel.cuh
│ │ │ │ ├── roi_align_rotated_cuda_kernel.cuh
│ │ │ │ ├── roi_pool_cuda_kernel.cuh
│ │ │ │ ├── roiaware_pool3d_cuda_kernel.cuh
│ │ │ │ ├── roipoint_pool3d_cuda_kernel.cuh
│ │ │ │ ├── rotated_feature_align_cuda_kernel.cuh
│ │ │ │ ├── scatter_points_cuda_kernel.cuh
│ │ │ │ ├── sigmoid_focal_loss_cuda_kernel.cuh
│ │ │ │ ├── softmax_focal_loss_cuda_kernel.cuh
│ │ │ │ ├── spconv
│ │ │ │ │ ├── indice.cuh
│ │ │ │ │ └── reordering.cuh
│ │ │ │ ├── stack_ball_query_cuda_kernel.cuh
│ │ │ │ ├── stack_group_points_cuda_kernel.cuh
│ │ │ │ ├── sync_bn_cuda_kernel.cuh
│ │ │ │ ├── three_interpolate_cuda_kernel.cuh
│ │ │ │ ├── three_nn_cuda_kernel.cuh
│ │ │ │ ├── tin_shift_cuda_kernel.cuh
│ │ │ │ └── voxelization_cuda_kernel.cuh
│ │ │ ├── mlu
│ │ │ │ ├── common_mlu_helper.hpp
│ │ │ │ ├── masked_conv2d_mlu_kernel.mlu
│ │ │ │ └── roi_pool_mlu_kernel.mlu
│ │ │ ├── mps
│ │ │ │ ├── MPSDevice.h
│ │ │ │ ├── MPSLibrary.h
│ │ │ │ ├── MPSLibrary.mm
│ │ │ │ ├── MPSStream.h
│ │ │ │ └── MPSUtils.h
│ │ │ ├── musa
│ │ │ │ ├── active_rotated_filter_musa_kernel.muh
│ │ │ │ ├── assign_score_withk_musa_kernel.muh
│ │ │ │ ├── ball_query_musa_kernel.muh
│ │ │ │ ├── bbox_overlaps_musa_kernel.muh
│ │ │ │ ├── bezier_align_musa_kernel.muh
│ │ │ │ ├── border_align_musa_kernel.muh
│ │ │ │ ├── box_iou_quadri_musa.muh
│ │ │ │ ├── box_iou_rotated_musa.muh
│ │ │ │ ├── carafe_musa_kernel.muh
│ │ │ │ ├── carafe_naive_musa_kernel.muh
│ │ │ │ ├── chamfer_distance_musa_kernel.muh
│ │ │ │ ├── common_musa_helper.hpp
│ │ │ │ ├── convex_iou_musa_kernel.muh
│ │ │ │ ├── correlation_musa.muh
│ │ │ │ ├── deform_conv_musa_kernel.muh
│ │ │ │ ├── deform_roi_pool_musa_kernel.muh
│ │ │ │ ├── diff_iou_rotated_musa_kernel.muh
│ │ │ │ ├── furthest_point_sample_musa_kernel.muh
│ │ │ │ ├── gather_points_musa_kernel.muh
│ │ │ │ ├── group_points_musa_kernel.muh
│ │ │ │ ├── iou3d_musa_kernel.muh
│ │ │ │ ├── knn_musa_kernel.muh
│ │ │ │ ├── masked_conv2d_musa_kernel.muh
│ │ │ │ ├── min_area_polygons_musa.muh
│ │ │ │ ├── modulated_deform_conv_musa_kernel.muh
│ │ │ │ ├── ms_deform_attn_musa_kernel.muh
│ │ │ │ ├── nms_musa_kernel.muh
│ │ │ │ ├── nms_quadri_musa.muh
│ │ │ │ ├── nms_rotated_musa.muh
│ │ │ │ ├── points_in_boxes_musa_kernel.muh
│ │ │ │ ├── points_in_polygons_musa_kernel.muh
│ │ │ │ ├── prroi_pool_musa_kernel.muh
│ │ │ │ ├── psamask_musa_kernel.muh
│ │ │ │ ├── riroi_align_rotated_musa_kernel.muh
│ │ │ │ ├── roi_align_musa_kernel.muh
│ │ │ │ ├── roi_align_rotated_musa_kernel.muh
│ │ │ │ ├── roi_pool_musa_kernel.muh
│ │ │ │ ├── roiaware_pool3d_musa_kernel.muh
│ │ │ │ ├── roipoint_pool3d_musa_kernel.muh
│ │ │ │ ├── rotated_feature_align_musa_kernel.muh
│ │ │ │ ├── scatter_points_musa_kernel.muh
│ │ │ │ ├── sigmoid_focal_loss_musa_kernel.muh
│ │ │ │ ├── softmax_focal_loss_musa_kernel.muh
│ │ │ │ ├── spconv
│ │ │ │ │ ├── indice.muh
│ │ │ │ │ └── reordering.muh
│ │ │ │ ├── stack_ball_query_musa_kernel.muh
│ │ │ │ ├── stack_group_points_musa_kernel.muh
│ │ │ │ ├── sync_bn_musa_kernel.muh
│ │ │ │ ├── three_interpolate_musa_kernel.muh
│ │ │ │ ├── three_nn_musa_kernel.muh
│ │ │ │ ├── tin_shift_musa_kernel.muh
│ │ │ │ └── voxelization_musa_kernel.muh
│ │ │ ├── parrots_cpp_helper.hpp
│ │ │ ├── parrots_cuda_helper.hpp
│ │ │ ├── pytorch_cpp_helper.hpp
│ │ │ ├── pytorch_cuda_helper.hpp
│ │ │ ├── pytorch_device_registry.hpp
│ │ │ ├── pytorch_mlu_helper.hpp
│ │ │ ├── pytorch_musa_helper.hpp
│ │ │ ├── pytorch_npu_helper.hpp
│ │ │ ├── pytorch_npu_util.hpp
│ │ │ └── utils
│ │ │ │ └── spconv
│ │ │ │ ├── paramsgrid.h
│ │ │ │ ├── prettyprint.h
│ │ │ │ ├── pybind11_utils.h
│ │ │ │ ├── spconv
│ │ │ │ ├── geometry.h
│ │ │ │ ├── indice.h
│ │ │ │ ├── maxpool.h
│ │ │ │ ├── mp_helper.h
│ │ │ │ ├── point2voxel.h
│ │ │ │ └── reordering.h
│ │ │ │ └── tensorview
│ │ │ │ ├── helper_kernel.cuh
│ │ │ │ ├── helper_kernel.muh
│ │ │ │ ├── helper_launch.h
│ │ │ │ └── tensorview.h
│ │ ├── parrots
│ │ │ ├── active_rotated_filter.cpp
│ │ │ ├── active_rotated_filter_parrots.cpp
│ │ │ ├── active_rotated_filter_pytorch.h
│ │ │ ├── assign_score_withk.cpp
│ │ │ ├── assign_score_withk_parrots.cpp
│ │ │ ├── assign_score_withk_pytorch.h
│ │ │ ├── ball_query._parrots.cpp
│ │ │ ├── ball_query.cpp
│ │ │ ├── ball_query_pytorch.h
│ │ │ ├── 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_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
│ │ │ ├── chamfer_distance.cpp
│ │ │ ├── chamfer_distance_parrots.cpp
│ │ │ ├── chamfer_distance_pytorch.h
│ │ │ ├── contour_expand.cpp
│ │ │ ├── contour_expand_parrots.cpp
│ │ │ ├── contour_expand_pytorch.h
│ │ │ ├── convex_iou.cpp
│ │ │ ├── convex_iou_parrots.cpp
│ │ │ ├── convex_iou_pytorch.h
│ │ │ ├── correlation.cpp
│ │ │ ├── correlation_parrots.cpp
│ │ │ ├── correlation_pytorch.h
│ │ │ ├── cudabind.cpp
│ │ │ ├── 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
│ │ │ ├── diff_iou_rotated.cpp
│ │ │ ├── diff_iou_rotated_parrots.cpp
│ │ │ ├── diff_iou_rotated_pytorch.h
│ │ │ ├── focal_loss.cpp
│ │ │ ├── focal_loss_parrots.cpp
│ │ │ ├── focal_loss_pytorch.h
│ │ │ ├── furthest_point_sample.cpp
│ │ │ ├── furthest_point_sample_parrots.cpp
│ │ │ ├── furthest_point_sample_pytorch.h
│ │ │ ├── fused_bias_leakyrelu.cpp
│ │ │ ├── fused_bias_parrots.cpp
│ │ │ ├── gather_points.cpp
│ │ │ ├── gather_points_parrots.cpp
│ │ │ ├── gather_points_pytorch.h
│ │ │ ├── group_points.cpp
│ │ │ ├── group_points_parrots.cpp
│ │ │ ├── group_points_pytorch.h
│ │ │ ├── info.cpp
│ │ │ ├── iou3d.cpp
│ │ │ ├── iou3d_parrots.cpp
│ │ │ ├── iou3d_pytorch.h
│ │ │ ├── knn.cpp
│ │ │ ├── knn_parrots.cpp
│ │ │ ├── knn_pytorch.h
│ │ │ ├── masked_conv2d.cpp
│ │ │ ├── masked_conv2d_parrots.cpp
│ │ │ ├── masked_conv2d_pytorch.h
│ │ │ ├── min_area_polygons.cpp
│ │ │ ├── min_area_polygons_parrots.cpp
│ │ │ ├── min_area_polygons_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
│ │ │ ├── pixel_group.cpp
│ │ │ ├── pixel_group_parrots.cpp
│ │ │ ├── pixel_group_pytorch.h
│ │ │ ├── points_in_boxes.cpp
│ │ │ ├── points_in_boxes_parrots.cpp
│ │ │ ├── points_in_boxes_pytorch.h
│ │ │ ├── points_in_polygons.cpp
│ │ │ ├── points_in_polygons_parrots.cpp
│ │ │ ├── points_in_polygons_pytorch.h
│ │ │ ├── prroi_pool.cpp
│ │ │ ├── prroi_pool_parrots.cpp
│ │ │ ├── prroi_pool_pytorch.h
│ │ │ ├── psamask.cpp
│ │ │ ├── psamask_parrots.cpp
│ │ │ ├── psamask_pytorch.h
│ │ │ ├── riroi_align_rotated.cpp
│ │ │ ├── riroi_align_rotated_parrots.cpp
│ │ │ ├── riroi_align_rotated_pytorch.h
│ │ │ ├── roi_align.cpp
│ │ │ ├── roi_align_parrots.cpp
│ │ │ ├── roi_align_pytorch.h
│ │ │ ├── roi_align_rotated.cpp
│ │ │ ├── roi_align_rotated_parrots.cpp
│ │ │ ├── roi_align_rotated_pytorch.h
│ │ │ ├── roi_pool.cpp
│ │ │ ├── roi_pool_parrots.cpp
│ │ │ ├── roi_pool_pytorch.h
│ │ │ ├── roiaware_pool3d.cpp
│ │ │ ├── roiaware_pool3d_parrots.cpp
│ │ │ ├── roiaware_pool3d_pytorch.h
│ │ │ ├── roipoint_pool3d.cpp
│ │ │ ├── roipoint_pool3d_parrots.cpp
│ │ │ ├── roipoint_pool3d_pytorch.h
│ │ │ ├── rotated_feature_align.cpp
│ │ │ ├── rotated_feature_align_parrots.cpp
│ │ │ ├── rotated_feature_align_pytorch.h
│ │ │ ├── sync_bn.cpp
│ │ │ ├── sync_bn_parrots.cpp
│ │ │ ├── sync_bn_pytorch.h
│ │ │ ├── three_interpolate.cpp
│ │ │ ├── three_interpolate_parrots.cpp
│ │ │ ├── three_interpolate_pytorch.h
│ │ │ ├── three_nn.cpp
│ │ │ ├── three_nn_parrots.cpp
│ │ │ ├── three_nn_pytorch.h
│ │ │ ├── tin_shift.cpp
│ │ │ ├── tin_shift_parrots.cpp
│ │ │ ├── tin_shift_pytorch.h
│ │ │ ├── upfirdn2d.cpp
│ │ │ ├── upfirdn2d_parrots.cpp
│ │ │ ├── voxelization.cpp
│ │ │ ├── voxelization_parrots.cpp
│ │ │ └── voxelization_pytorch.h
│ │ └── pytorch
│ │ │ ├── active_rotated_filter.cpp
│ │ │ ├── assign_score_withk.cpp
│ │ │ ├── ball_query.cpp
│ │ │ ├── bbox_overlaps.cpp
│ │ │ ├── bezier_align.cpp
│ │ │ ├── bias_act.cpp
│ │ │ ├── border_align.cpp
│ │ │ ├── box_iou_quadri.cpp
│ │ │ ├── box_iou_rotated.cpp
│ │ │ ├── carafe.cpp
│ │ │ ├── carafe_naive.cpp
│ │ │ ├── chamfer_distance.cpp
│ │ │ ├── contour_expand.cpp
│ │ │ ├── convex_iou.cpp
│ │ │ ├── correlation.cpp
│ │ │ ├── cpu
│ │ │ ├── active_rotated_filter.cpp
│ │ │ ├── bbox_overlaps_cpu.cpp
│ │ │ ├── bezier_align.cpp
│ │ │ ├── box_iou_quadri.cpp
│ │ │ ├── box_iou_rotated.cpp
│ │ │ ├── deform_conv.cpp
│ │ │ ├── modulated_deform_conv.cpp
│ │ │ ├── nms.cpp
│ │ │ ├── nms_quadri.cpp
│ │ │ ├── nms_rotated.cpp
│ │ │ ├── pixel_group.cpp
│ │ │ ├── points_in_boxes.cpp
│ │ │ ├── psamask.cpp
│ │ │ ├── roi_align.cpp
│ │ │ ├── roi_align_rotated.cpp
│ │ │ ├── rotated_feature_align.cpp
│ │ │ ├── sparse_indice.cpp
│ │ │ ├── sparse_maxpool.cpp
│ │ │ ├── sparse_reordering.cpp
│ │ │ └── voxelization.cpp
│ │ │ ├── cuda
│ │ │ ├── active_rotated_filter_cuda.cu
│ │ │ ├── assign_score_withk_cuda.cu
│ │ │ ├── ball_query_cuda.cu
│ │ │ ├── bbox_overlaps_cuda.cu
│ │ │ ├── bezier_align_cuda.cu
│ │ │ ├── bias_act_cuda.cu
│ │ │ ├── border_align_cuda.cu
│ │ │ ├── box_iou_quadri_cuda.cu
│ │ │ ├── box_iou_rotated_cuda.cu
│ │ │ ├── carafe_cuda.cu
│ │ │ ├── carafe_naive_cuda.cu
│ │ │ ├── chamfer_distance_cuda.cu
│ │ │ ├── convex_iou.cu
│ │ │ ├── correlation_cuda.cu
│ │ │ ├── cudabind.cpp
│ │ │ ├── deform_conv_cuda.cu
│ │ │ ├── deform_roi_pool_cuda.cu
│ │ │ ├── diff_iou_rotated_cuda.cu
│ │ │ ├── filtered_lrelu.cu
│ │ │ ├── focal_loss_cuda.cu
│ │ │ ├── furthest_point_sample_cuda.cu
│ │ │ ├── fused_bias_leakyrelu_cuda.cu
│ │ │ ├── fused_spconv_ops_cuda.cu
│ │ │ ├── gather_points_cuda.cu
│ │ │ ├── group_points_cuda.cu
│ │ │ ├── iou3d_cuda.cu
│ │ │ ├── knn_cuda.cu
│ │ │ ├── masked_conv2d_cuda.cu
│ │ │ ├── min_area_polygons.cu
│ │ │ ├── modulated_deform_conv_cuda.cu
│ │ │ ├── ms_deform_attn_cuda.cu
│ │ │ ├── nms_cuda.cu
│ │ │ ├── nms_quadri_cuda.cu
│ │ │ ├── nms_rotated_cuda.cu
│ │ │ ├── points_in_boxes_cuda.cu
│ │ │ ├── points_in_polygons_cuda.cu
│ │ │ ├── prroi_pool_cuda.cu
│ │ │ ├── psamask_cuda.cu
│ │ │ ├── riroi_align_rotated_cuda.cu
│ │ │ ├── roi_align_cuda.cu
│ │ │ ├── roi_align_rotated_cuda.cu
│ │ │ ├── roi_pool_cuda.cu
│ │ │ ├── roiaware_pool3d_cuda.cu
│ │ │ ├── roipoint_pool3d_cuda.cu
│ │ │ ├── rotated_feature_align_cuda.cu
│ │ │ ├── scatter_points_cuda.cu
│ │ │ ├── sparse_indice.cu
│ │ │ ├── sparse_maxpool.cu
│ │ │ ├── sparse_pool_ops_cuda.cu
│ │ │ ├── sparse_reordering.cu
│ │ │ ├── spconv_ops_cuda.cu
│ │ │ ├── stack_ball_query_cuda.cu
│ │ │ ├── stack_group_points_cuda.cu
│ │ │ ├── sync_bn_cuda.cu
│ │ │ ├── three_interpolate_cuda.cu
│ │ │ ├── three_nn_cuda.cu
│ │ │ ├── tin_shift_cuda.cu
│ │ │ ├── upfirdn2d_kernel.cu
│ │ │ └── voxelization_cuda.cu
│ │ │ ├── deform_conv.cpp
│ │ │ ├── deform_roi_pool.cpp
│ │ │ ├── diff_iou_rotated.cpp
│ │ │ ├── filtered_lrelu.cpp
│ │ │ ├── focal_loss.cpp
│ │ │ ├── furthest_point_sample.cpp
│ │ │ ├── fused_bias_leakyrelu.cpp
│ │ │ ├── fused_spconv_ops.cpp
│ │ │ ├── gather_points.cpp
│ │ │ ├── group_points.cpp
│ │ │ ├── info.cpp
│ │ │ ├── iou3d.cpp
│ │ │ ├── knn.cpp
│ │ │ ├── masked_conv2d.cpp
│ │ │ ├── min_area_polygons.cpp
│ │ │ ├── mlu
│ │ │ ├── ball_query_mlu.cpp
│ │ │ ├── bbox_overlaps_mlu.cpp
│ │ │ ├── box_iou_rotated.cpp
│ │ │ ├── carafe_mlu.cpp
│ │ │ ├── deform_roi_pool_mlu.cpp
│ │ │ ├── diff_iou_rotated_mlu.cpp
│ │ │ ├── focal_loss_sigmoid_mlu.cpp
│ │ │ ├── iou3d_mlu.cpp
│ │ │ ├── masked_conv2d_mlu.cpp
│ │ │ ├── mlu_common_helper.cpp
│ │ │ ├── mlu_common_helper.h
│ │ │ ├── ms_deform_attn_mlu.cpp
│ │ │ ├── nms_mlu.cpp
│ │ │ ├── nms_rotated_mlu.cpp
│ │ │ ├── psamask_mlu.cpp
│ │ │ ├── roi_align_mlu.cpp
│ │ │ ├── roi_align_rotated_mlu.cpp
│ │ │ ├── roi_pool_mlu.cpp
│ │ │ ├── roiaware_pool3d_mlu.cpp
│ │ │ ├── roipoint_pool3d_mlu.cpp
│ │ │ ├── rotated_feature_align_mlu.cpp
│ │ │ ├── scatter_points_mlu.cpp
│ │ │ ├── sparse_conv_mlu.cpp
│ │ │ ├── three_nn_mlu.cpp
│ │ │ ├── tin_shift_mlu.cpp
│ │ │ └── voxelization_mlu.cpp
│ │ │ ├── modulated_deform_conv.cpp
│ │ │ ├── mps
│ │ │ └── bbox_overlaps_mps.mm
│ │ │ ├── ms_deform_attn.cpp
│ │ │ ├── musa
│ │ │ ├── active_rotated_filter_musa.mu
│ │ │ ├── assign_score_withk_musa.mu
│ │ │ ├── ball_query_musa.mu
│ │ │ ├── bbox_overlaps_musa.mu
│ │ │ ├── bezier_align_musa.mu
│ │ │ ├── bias_act_musa.mu
│ │ │ ├── border_align_musa.mu
│ │ │ ├── box_iou_quadri_musa.mu
│ │ │ ├── box_iou_rotated_musa.mu
│ │ │ ├── carafe_musa.mu
│ │ │ ├── carafe_naive_musa.mu
│ │ │ ├── chamfer_distance_musa.mu
│ │ │ ├── convex_iou.mu
│ │ │ ├── correlation_musa.mu
│ │ │ ├── deform_conv_musa.mu
│ │ │ ├── deform_roi_pool_musa.mu
│ │ │ ├── diff_iou_rotated_musa.mu
│ │ │ ├── filtered_lrelu.mu
│ │ │ ├── focal_loss_musa.mu
│ │ │ ├── furthest_point_sample_musa.mu
│ │ │ ├── fused_bias_leakyrelu_musa.mu
│ │ │ ├── fused_spconv_ops_musa.mu
│ │ │ ├── gather_points_musa.mu
│ │ │ ├── group_points_musa.mu
│ │ │ ├── iou3d_musa.mu
│ │ │ ├── knn_musa.mu
│ │ │ ├── masked_conv2d_musa.mu
│ │ │ ├── min_area_polygons.mu
│ │ │ ├── modulated_deform_conv_musa.mu
│ │ │ ├── ms_deform_attn_musa.mu
│ │ │ ├── musabind.cpp
│ │ │ ├── nms_musa.mu
│ │ │ ├── nms_quadri_musa.mu
│ │ │ ├── nms_rotated_musa.mu
│ │ │ ├── points_in_boxes_musa.mu
│ │ │ ├── points_in_polygons_musa.mu
│ │ │ ├── prroi_pool_musa.mu
│ │ │ ├── psamask_musa.mu
│ │ │ ├── riroi_align_rotated_musa.mu
│ │ │ ├── roi_align_musa.mu
│ │ │ ├── roi_align_rotated_musa.mu
│ │ │ ├── roi_pool_musa.mu
│ │ │ ├── roiaware_pool3d_musa.mu
│ │ │ ├── roipoint_pool3d_musa.mu
│ │ │ ├── rotated_feature_align_musa.mu
│ │ │ ├── scatter_points_musa.mu
│ │ │ ├── sparse_indice.mu
│ │ │ ├── sparse_maxpool.mu
│ │ │ ├── sparse_pool_ops_musa.mu
│ │ │ ├── sparse_reordering.mu
│ │ │ ├── spconv_ops_musa.mu
│ │ │ ├── stack_ball_query_musa.mu
│ │ │ ├── stack_group_points_musa.mu
│ │ │ ├── sync_bn_musa.mu
│ │ │ ├── three_interpolate_musa.mu
│ │ │ ├── three_nn_musa.mu
│ │ │ ├── tin_shift_musa.mu
│ │ │ ├── upfirdn2d_kernel.mu
│ │ │ └── voxelization_musa.mu
│ │ │ ├── nms.cpp
│ │ │ ├── nms_quadri.cpp
│ │ │ ├── nms_rotated.cpp
│ │ │ ├── npu
│ │ │ ├── active_rotated_filter_npu.cpp
│ │ │ ├── assign_score_withk_npu.cpp
│ │ │ ├── ball_query_npu.cpp
│ │ │ ├── bbox_overlaps_npu.cpp
│ │ │ ├── border_align_npu.cpp
│ │ │ ├── box_iou_quadri_npu.cpp
│ │ │ ├── box_iou_rotated_npu.cpp
│ │ │ ├── boxes_overlap_bev_npu.cpp
│ │ │ ├── chamfer_distance_npu.cpp
│ │ │ ├── common_util.h
│ │ │ ├── deform_roi_pool.cpp
│ │ │ ├── diff_iou_rotated_npu.cpp
│ │ │ ├── focal_loss_npu.cpp
│ │ │ ├── furthest_point_sample_npu.cpp
│ │ │ ├── furthest_point_sampling_with_dist_npu.cpp
│ │ │ ├── fused_bias_leakyrelu_npu.cpp
│ │ │ ├── gather_points_npu.cpp
│ │ │ ├── group_points_npu.cpp
│ │ │ ├── knn_npu.cpp
│ │ │ ├── ms_deform_attn_npu.cpp
│ │ │ ├── nms3d_normal_npu.cpp
│ │ │ ├── nms3d_npu.cpp
│ │ │ ├── nms_npu.cpp
│ │ │ ├── nms_rotated_npu.cpp
│ │ │ ├── points_in_box_npu.cpp
│ │ │ ├── points_in_box_npu_all.cpp
│ │ │ ├── points_in_polygons_npu.cpp
│ │ │ ├── psa_mask_npu.cpp
│ │ │ ├── roi_align_npu.cpp
│ │ │ ├── roi_align_rotated_npu.cpp
│ │ │ ├── roi_pool_npu.cpp
│ │ │ ├── roiaware_pool3d_npu.cpp
│ │ │ ├── roipoint_pool3d_forward.cpp
│ │ │ ├── rotated_feature_align_npu.cpp
│ │ │ ├── stack_ball_query_npu.cpp
│ │ │ ├── stack_group_points_npu.cpp
│ │ │ ├── three_interpolate_npu.cpp
│ │ │ ├── three_nn_npu.cpp
│ │ │ └── voxelization_npu.cpp
│ │ │ ├── pixel_group.cpp
│ │ │ ├── points_in_boxes.cpp
│ │ │ ├── points_in_polygons.cpp
│ │ │ ├── prroi_pool.cpp
│ │ │ ├── psamask.cpp
│ │ │ ├── pybind.cpp
│ │ │ ├── riroi_align_rotated.cpp
│ │ │ ├── roi_align.cpp
│ │ │ ├── roi_align_rotated.cpp
│ │ │ ├── roi_pool.cpp
│ │ │ ├── roiaware_pool3d.cpp
│ │ │ ├── roipoint_pool3d.cpp
│ │ │ ├── rotated_feature_align.cpp
│ │ │ ├── scatter_points.cpp
│ │ │ ├── sparse_pool_ops.cpp
│ │ │ ├── spconv_ops.cpp
│ │ │ ├── spconv_utils.h
│ │ │ ├── sync_bn.cpp
│ │ │ ├── three_interpolate.cpp
│ │ │ ├── three_nn.cpp
│ │ │ ├── tin_shift.cpp
│ │ │ ├── upfirdn2d.cpp
│ │ │ └── voxelization.cpp
│ ├── deform_conv.py
│ ├── deform_roi_pool.py
│ ├── deprecated_wrappers.py
│ ├── diff_iou_rotated.py
│ ├── filtered_lrelu.py
│ ├── focal_loss.py
│ ├── furthest_point_sample.py
│ ├── fused_bias_leakyrelu.py
│ ├── gather_points.py
│ ├── group_points.py
│ ├── info.py
│ ├── iou3d.py
│ ├── knn.py
│ ├── masked_conv.py
│ ├── merge_cells.py
│ ├── min_area_polygons.py
│ ├── modulated_deform_conv.py
│ ├── multi_scale_deform_attn.py
│ ├── nms.py
│ ├── pixel_group.py
│ ├── point_sample.py
│ ├── points_in_boxes.py
│ ├── points_in_polygons.py
│ ├── points_sampler.py
│ ├── prroi_pool.py
│ ├── psa_mask.py
│ ├── riroi_align_rotated.py
│ ├── roi_align.py
│ ├── roi_align_rotated.py
│ ├── roi_pool.py
│ ├── roiaware_pool3d.py
│ ├── roipoint_pool3d.py
│ ├── rotated_feature_align.py
│ ├── saconv.py
│ ├── scatter_points.py
│ ├── sparse_conv.py
│ ├── sparse_functional.py
│ ├── sparse_modules.py
│ ├── sparse_ops.py
│ ├── sparse_pool.py
│ ├── sparse_structure.py
│ ├── sync_bn.py
│ ├── three_interpolate.py
│ ├── three_nn.py
│ ├── tin_shift.py
│ ├── upfirdn2d.py
│ └── voxelize.py
├── transforms
│ ├── __init__.py
│ ├── base.py
│ ├── builder.py
│ ├── formatting.py
│ ├── loading.py
│ ├── processing.py
│ ├── utils.py
│ └── wrappers.py
├── utils
│ ├── __init__.py
│ ├── device_type.py
│ ├── env.py
│ ├── ext_loader.py
│ └── parrots_jit.py
├── version.py
├── video
│ ├── __init__.py
│ ├── io.py
│ ├── optflow.py
│ └── processing.py
└── visualization
│ ├── __init__.py
│ ├── color.py
│ ├── image.py
│ └── optflow.py
├── requirements.txt
├── requirements
├── build.txt
├── docs.txt
├── optional.txt
├── runtime.txt
└── test.txt
├── setup.cfg
├── setup.py
└── tests
├── data
├── batched_nms_data.pkl
├── color.jpg
├── color_exif.jpg
├── config
│ ├── a.b.py
│ ├── a.py
│ ├── b.json
│ ├── base.py
│ ├── c.yaml
│ ├── code.py
│ ├── d.py
│ ├── delete.py
│ ├── deprecated.py
│ ├── deprecated_as_base.py
│ ├── e.py
│ ├── expected.py
│ ├── f.py
│ ├── g.py
│ ├── h.py
│ ├── i_base.py
│ ├── i_child.py
│ ├── l.py
│ ├── l1.py
│ ├── l2.yaml
│ ├── l3.json
│ ├── l4.py
│ ├── m.py
│ ├── n.py
│ ├── o.json
│ ├── p.yaml
│ ├── q.py
│ ├── r.py
│ ├── s.py
│ ├── t.json
│ ├── t.py
│ ├── t.yaml
│ ├── u.json
│ ├── u.py
│ ├── u.yaml
│ └── v.py
├── demo.lmdb
│ ├── data.mdb
│ └── lock.mdb
├── filelist.txt
├── for_3d_ops
│ ├── features_for_fps_distance.npy
│ ├── fps_idx.npy
│ └── test_voxel.npy
├── for_carafe
│ ├── carafe_feat.bin
│ ├── carafe_feat_grad.bin
│ ├── carafe_mask.bin
│ ├── carafe_mask_grad.bin
│ └── carafe_output.bin
├── for_ccattention
│ ├── ccattention_input.bin
│ └── ccattention_output.bin
├── for_masked_conv2d
│ ├── masked_conv2d_for_bias.npy
│ ├── masked_conv2d_for_input.npy
│ ├── masked_conv2d_for_mask.npy
│ ├── masked_conv2d_for_output.npy
│ └── masked_conv2d_for_weight.npy
├── for_psa_mask
│ ├── psa_input.bin
│ ├── psa_output_collect.bin
│ └── psa_output_distribute.bin
├── for_scan
│ ├── .file
│ ├── 1.json
│ ├── 1.txt
│ ├── 2.json
│ ├── 2.txt
│ ├── 3.TXT
│ ├── a.bin
│ └── sub
│ │ ├── 1.json
│ │ └── 1.txt
├── gray_alpha.png
├── grayscale.jpg
├── grayscale_dim3.jpg
├── mapping.txt
├── optflow.flo
├── optflow_concat0.jpg
├── optflow_concat1.jpg
├── palette.gif
├── patches
│ ├── 0.npy
│ ├── 1.npy
│ ├── 2.npy
│ ├── 3.npy
│ ├── 4.npy
│ ├── pad0_0.npy
│ ├── pad0_1.npy
│ ├── pad0_2.npy
│ ├── pad0_3.npy
│ ├── pad0_4.npy
│ ├── pad_0.npy
│ ├── pad_1.npy
│ ├── pad_2.npy
│ ├── pad_3.npy
│ ├── pad_4.npy
│ ├── scale_0.npy
│ ├── scale_1.npy
│ ├── scale_2.npy
│ ├── scale_3.npy
│ └── scale_4.npy
├── scripts
│ └── hello.py
├── sparse_flow.png
├── test.mp4
└── uint16-5channel.tif
├── test_arraymisc.py
├── test_cnn
├── test_build_layers.py
├── test_context_block.py
├── test_conv2d_adaptive_padding.py
├── test_conv_module.py
├── test_depthwise_seperable_conv_module.py
├── test_flops_counter.py
├── test_fuse_conv_bn.py
├── test_generalized_attention.py
├── test_hsigmoid.py
├── test_hswish.py
├── test_non_local.py
├── test_rfsearch
│ ├── test_operator.py
│ └── test_search.py
├── test_scale.py
├── test_silu.py
├── test_swish.py
├── test_transformer.py
└── test_wrappers.py
├── test_image
├── test_colorspace.py
├── test_geometric.py
├── test_image_misc.py
├── test_io.py
└── test_photometric.py
├── test_ops
├── output.pkl
├── test_active_rotated_filter.py
├── test_assign_score_withk.py
├── test_ball_query.py
├── test_bbox.py
├── test_bezier_align.py
├── test_bias_act.py
├── test_bilinear_grid_sample.py
├── test_border_align.py
├── test_box_iou_quadri.py
├── test_box_iou_rotated.py
├── test_carafe.py
├── test_cc_attention.py
├── test_chamfer_distance.py
├── test_contour_expand.py
├── test_conv_gradfix.py
├── test_convex_iou.py
├── test_corner_pool.py
├── test_correlation.py
├── test_deform_conv.py
├── test_deform_roi_pool.py
├── test_diff_iou_rotated.py
├── test_filtered_lrelu.py
├── test_focal_loss.py
├── test_furthest_point_sample.py
├── test_fused_bias_leakyrelu.py
├── test_gather_points.py
├── test_group_points.py
├── test_info.py
├── test_iou3d.py
├── test_knn.py
├── test_masked_conv2d.py
├── test_merge_cells.py
├── test_min_area_polygons.py
├── test_modulated_deform_conv.py
├── test_ms_deformable_attn.py
├── test_nms.py
├── test_nms_quadri.py
├── test_nms_rotated.py
├── test_onnx.py
├── test_pixel_group.py
├── test_points_in_polygons.py
├── test_prroi_pool.py
├── test_psa_mask.py
├── test_riroi_align_rotated.py
├── test_roi_align.py
├── test_roi_align_rotated.py
├── test_roi_pool.py
├── test_roiaware_pool3d.py
├── test_roipoint_pool3d.py
├── test_rotated_feature_align.py
├── test_saconv.py
├── test_scatter_points.py
├── test_spconv.py
├── test_syncbn.py
├── test_three_interpolate.py
├── test_three_nn.py
├── test_tin_shift.py
├── test_upfirdn2d.py
└── test_voxelization.py
├── test_transforms
├── test_transforms_formatting.py
├── test_transforms_loading.py
├── test_transforms_processing.py
└── test_transforms_wrapper.py
├── test_utils
├── test_env.py
└── test_parrots_jit.py
├── test_video
├── test_optflow.py
├── test_processing.py
└── test_reader.py
└── test_visualization.py
/.dockerignore:
--------------------------------------------------------------------------------
1 | .git
2 | .gitignore
3 | *.egg-info
4 | .eggs/
5 | .mypy-cache
6 | pip-wheel-metadata
7 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/3-documentation.yml:
--------------------------------------------------------------------------------
1 | name: 📚 Documentation
2 | description: Report an issue related to the documentation.
3 | labels: "docs"
4 | title: "[Docs] "
5 |
6 | body:
7 | - type: markdown
8 | attributes:
9 | value: |
10 | ## Note
11 | For general usage questions or idea discussions, please post it to our [**Forum**](https://github.com/open-mmlab/mmcv/discussions)
12 | Please fill in as **much** of the following form as you're able to. **The clearer the description, the shorter it will take to solve it.**
13 |
14 | - type: textarea
15 | attributes:
16 | label: 📚 The doc issue
17 | description: >
18 | A clear and concise description the issue.
19 | validations:
20 | required: true
21 |
22 | - type: textarea
23 | attributes:
24 | label: Suggest a potential alternative/fix
25 | description: >
26 | Tell us how we could improve the documentation in this regard.
27 |
28 | - type: markdown
29 | attributes:
30 | value: |
31 | ## Acknowledgement
32 | Thanks for taking the time to fill out this report.
33 |
34 | If you have already identified the reason, we strongly appreciate you creating a new PR to fix it [**here**](https://github.com/open-mmlab/mmcv/pulls)!
35 | Please refer to [**Contribution Guide**](https://mmcv.readthedocs.io/en/latest/community/contributing.html) for contributing.
36 |
37 | Welcome to join our [**Community(TODO)**](https://mmcv.readthedocs.io/en/latest/contact.html) to discuss together. 👬
38 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 |
3 | contact_links:
4 | - name: 💬 Forum
5 | url: https://github.com/open-mmlab/mmcv/discussions
6 | about: Ask general usage questions and discuss with other mmcv community members
7 | - name: MMCV Documentation
8 | url: https://mmcv.readthedocs.io/en/latest/
9 | about: Check if your question is answered in docs
10 | - name: 🌐 Explore OpenMMLab
11 | url: https://openmmlab.com/
12 | about: Get know more about OpenMMLab
13 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | name: lint
2 |
3 | on: [push, pull_request]
4 |
5 | concurrency:
6 | group: ${{ github.workflow }}-${{ github.ref }}
7 | cancel-in-progress: true
8 |
9 | jobs:
10 | lint:
11 | runs-on: ubuntu-22.04
12 | steps:
13 | - uses: actions/checkout@v2
14 | - name: Set up Python 3.10.15
15 | uses: actions/setup-python@v2
16 | with:
17 | python-version: '3.10.15'
18 | - name: Install pre-commit hook
19 | run: |
20 | pip install pre-commit
21 | pre-commit install
22 | - name: Linting
23 | run: pre-commit run --all-files
24 | - name: Format c/cuda codes with clang-format
25 | uses: DoozyX/clang-format-lint-action@v0.18
26 | with:
27 | source: mmcv/ops/csrc
28 | extensions: h,c,cpp,hpp,cu,cuh
29 | style: google
30 |
--------------------------------------------------------------------------------
/.readthedocs.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 |
3 | formats: all
4 |
5 | build:
6 | os: ubuntu-22.04
7 | tools:
8 | python: "3.7"
9 |
10 | python:
11 | install:
12 | - requirements: requirements/runtime.txt
13 | - requirements: requirements/docs.txt
14 |
--------------------------------------------------------------------------------
/CITATION.cff:
--------------------------------------------------------------------------------
1 | cff-version: 1.2.0
2 | message: "If you use this software, please cite it as below."
3 | authors:
4 | - name: "MMCV Contributors"
5 | title: "OpenMMLab Computer Vision Foundation"
6 | date-released: 2018-08-22
7 | url: "https://github.com/open-mmlab/mmcv"
8 | license: Apache-2.0
9 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include requirements/runtime.txt
2 | include mmcv/ops/csrc/common/cuda/*.cuh mmcv/ops/csrc/common/cuda/*.hpp mmcv/ops/csrc/common/*.hpp
3 | include mmcv/ops/csrc/pytorch/*.cpp mmcv/ops/csrc/pytorch/cuda/*.cu mmcv/ops/csrc/pytorch/cuda/*.cpp mmcv/ops/csrc/pytorch/cpu/*.cpp
4 | include mmcv/ops/csrc/parrots/*.h mmcv/ops/csrc/parrots/*.cpp
5 | include mmcv/ops/csrc/pytorch/mps/*.mm mmcv/ops/csrc/common/mps/*.h mmcv/ops/csrc/common/mps/*.mm
6 | recursive-include mmcv/ops/csrc/ *.h *.hpp *.cpp *.cuh *.cu *.mm
7 |
--------------------------------------------------------------------------------
/TERMINOLOGY.md:
--------------------------------------------------------------------------------
1 | # English-Chinese terminology comparison (英汉术语对照)
2 |
3 | This document is used as a reference for English-Chinese terminology translation.
4 |
5 | 该文档用作中英文翻译对照参考。
6 |
7 | | English | 中文 |
8 | | :---------------: | :----------: |
9 | | annotation | 标注 |
10 | | backbone | 主干网络 |
11 | | benchmark | 基准测试 |
12 | | checkpoint | 模型权重文件 |
13 | | classifier | 分类器 |
14 | | cls_head | 分类头 |
15 | | decoder | 解码器 |
16 | | detector | 检测器 |
17 | | encoder | 编码器 |
18 | | finetune | 微调 |
19 | | ground truth | 真实标签 |
20 | | hook | 钩子 |
21 | | localizer | 定位器 |
22 | | neck | 模型颈部 |
23 | | pipeline | 流水线 |
24 | | recognizer | 识别器 |
25 | | register | 注册器 |
26 | | schedule | 调整 |
27 | | scheduler | 调度器 |
28 | | segmentor | 分割器 |
29 | | tensor | 张量 |
30 | | training schedule | 训练策略 |
31 |
--------------------------------------------------------------------------------
/docker/dev/Dockerfile:
--------------------------------------------------------------------------------
1 | ARG PYTORCH="1.8.1"
2 | ARG CUDA="10.2"
3 | ARG CUDNN="7"
4 |
5 | FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
6 |
7 | # To fix GPG key error when running apt-get update
8 | RUN rm /etc/apt/sources.list.d/cuda.list \
9 | && rm /etc/apt/sources.list.d/nvidia-ml.list \
10 | && apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub \
11 | && apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
12 |
13 | # Install git and system dependencies for opencv-python
14 | RUN apt-get update && apt-get install -y git \
15 | && apt-get update && apt-get install -y libgl1 libglib2.0-0
16 |
17 | # Install system dependencies for unit tests
18 | RUN apt-get install -y ffmpeg libturbojpeg \
19 | && apt-get clean \
20 | && rm -rf /var/lib/apt/lists/*
21 |
22 | # build mmcv from source with develop mode
23 | ARG HTTPS_PROXY=""
24 | ENV https_proxy=${HTTPS_PROXY}
25 | ENV FORCE_CUDA="1"
26 | ARG CUDA_ARCH=""
27 | ENV TORCH_CUDA_ARCH_LIST=${CUDA_ARCH}
28 | RUN git clone https://github.com/open-mmlab/mmcv.git /mmcv
29 | WORKDIR /mmcv
30 | RUN git checkout 2.x && git rev-parse --short HEAD
31 | RUN pip install --no-cache-dir -e .[all] -v && pip install pre-commit && pre-commit install
32 |
--------------------------------------------------------------------------------
/docker/release/Dockerfile:
--------------------------------------------------------------------------------
1 | ARG PYTORCH="1.8.1"
2 | ARG CUDA="10.2"
3 | ARG CUDNN="7"
4 |
5 | FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
6 |
7 | # To fix GPG key error when running apt-get update
8 | RUN rm /etc/apt/sources.list.d/cuda.list \
9 | && rm /etc/apt/sources.list.d/nvidia-ml.list \
10 | && apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub \
11 | && apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
12 |
13 | # Install system dependencies for opencv-python
14 | RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 \
15 | && apt-get clean \
16 | && rm -rf /var/lib/apt/lists/*
17 |
18 | # Install mmcv
19 | ARG MMCV=""
20 | RUN if [ "${MMCV}" = "" ]; then pip install -U openmim && mim install 'mmcv>=2.0.0rc1'; else pip install -U openmim && mim install mmcv==${MMCV}; fi
21 |
22 | # Verify the installation
23 | RUN python -c 'import mmcv;print(mmcv.__version__)'
24 |
--------------------------------------------------------------------------------
/docs/en/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SOURCEDIR = .
8 | BUILDDIR = _build
9 |
10 | # Put it first so that "make" without argument is like "make help".
11 | help:
12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13 |
14 | .PHONY: help Makefile
15 |
16 | # Catch-all target: route all unknown targets to Sphinx using the new
17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
18 | %: Makefile
19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20 |
--------------------------------------------------------------------------------
/docs/en/_static/community/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/community/1.png
--------------------------------------------------------------------------------
/docs/en/_static/community/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/community/2.png
--------------------------------------------------------------------------------
/docs/en/_static/community/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/community/3.png
--------------------------------------------------------------------------------
/docs/en/_static/css/readthedocs.css:
--------------------------------------------------------------------------------
1 | .header-logo {
2 | background-image: url("../image/mmcv-logo.png");
3 | background-size: 85px 40px;
4 | height: 40px;
5 | width: 85px;
6 | }
7 |
8 | table.colwidths-auto td {
9 | width: 50%
10 | }
11 |
--------------------------------------------------------------------------------
/docs/en/_static/flow_img2toimg1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/flow_img2toimg1.png
--------------------------------------------------------------------------------
/docs/en/_static/flow_raw_images.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/flow_raw_images.png
--------------------------------------------------------------------------------
/docs/en/_static/flow_visualization.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/flow_visualization.png
--------------------------------------------------------------------------------
/docs/en/_static/flow_warp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/flow_warp.png
--------------------------------------------------------------------------------
/docs/en/_static/flow_warp_diff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/flow_warp_diff.png
--------------------------------------------------------------------------------
/docs/en/_static/image/mmcv-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/image/mmcv-logo.png
--------------------------------------------------------------------------------
/docs/en/_static/parallel_progress.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/parallel_progress.gif
--------------------------------------------------------------------------------
/docs/en/_static/parallel_progress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/parallel_progress.png
--------------------------------------------------------------------------------
/docs/en/_static/progress.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/progress.gif
--------------------------------------------------------------------------------
/docs/en/_static/progress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/_static/progress.png
--------------------------------------------------------------------------------
/docs/en/_templates/classtemplate.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 | .. currentmodule:: {{ module }}
4 |
5 |
6 | {{ name | underline}}
7 |
8 | .. autoclass:: {{ name }}
9 | :members:
10 |
11 |
12 | ..
13 | autogenerated from source/_templates/classtemplate.rst
14 | note it does not have :inherited-members:
15 |
--------------------------------------------------------------------------------
/docs/en/api/arraymisc.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.arraymisc
5 | ===================================
6 |
7 | .. contents:: mmcv.arraymisc
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.arraymisc
13 |
14 | .. autosummary::
15 | :toctree: generated
16 | :nosignatures:
17 |
18 | quantize
19 | dequantize
20 |
--------------------------------------------------------------------------------
/docs/en/api/cnn.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.cnn
5 | ===================================
6 |
7 | .. contents:: mmcv.cnn
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.cnn
13 |
14 | Module
15 | ----------------
16 |
17 | .. autosummary::
18 | :toctree: generated
19 | :nosignatures:
20 | :template: classtemplate.rst
21 |
22 | ContextBlock
23 | Conv2d
24 | Conv3d
25 | ConvAWS2d
26 | ConvModule
27 | ConvTranspose2d
28 | ConvTranspose3d
29 | ConvWS2d
30 | DepthwiseSeparableConvModule
31 | GeneralizedAttention
32 | HSigmoid
33 | HSwish
34 | LayerScale
35 | Linear
36 | MaxPool2d
37 | MaxPool3d
38 | NonLocal1d
39 | NonLocal2d
40 | NonLocal3d
41 | Scale
42 | Swish
43 | Conv2dRFSearchOp
44 |
45 | Build Function
46 | ----------------
47 |
48 | .. autosummary::
49 | :toctree: generated
50 | :nosignatures:
51 |
52 | build_activation_layer
53 | build_conv_layer
54 | build_norm_layer
55 | build_padding_layer
56 | build_plugin_layer
57 | build_upsample_layer
58 |
59 | Miscellaneous
60 | ----------------
61 |
62 | .. autosummary::
63 | :toctree: generated
64 | :nosignatures:
65 |
66 | fuse_conv_bn
67 | conv_ws_2d
68 | is_norm
69 | make_res_layer
70 | make_vgg_layer
71 | get_model_complexity_info
72 |
--------------------------------------------------------------------------------
/docs/en/api/transforms.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.transforms
5 | ===================================
6 |
7 | .. currentmodule:: mmcv.transforms
8 |
9 | .. autosummary::
10 | :toctree: generated
11 | :nosignatures:
12 | :template: classtemplate.rst
13 |
14 | BaseTransform
15 | TestTimeAug
16 |
17 | Loading
18 | ----------------
19 |
20 | .. autosummary::
21 | :toctree: generated
22 | :nosignatures:
23 | :template: classtemplate.rst
24 |
25 | LoadAnnotations
26 | LoadImageFromFile
27 |
28 | Processing
29 | ----------------
30 |
31 | .. autosummary::
32 | :toctree: generated
33 | :nosignatures:
34 | :template: classtemplate.rst
35 |
36 | CenterCrop
37 | MultiScaleFlipAug
38 | Normalize
39 | Pad
40 | RandomChoiceResize
41 | RandomFlip
42 | RandomGrayscale
43 | RandomResize
44 | Resize
45 | ToTensor
46 | ImageToTensor
47 |
48 | Wrapper
49 | ----------------
50 |
51 | .. autosummary::
52 | :toctree: generated
53 | :nosignatures:
54 | :template: classtemplate.rst
55 |
56 | Compose
57 | KeyMapper
58 | RandomApply
59 | RandomChoice
60 | TransformBroadcaster
61 |
--------------------------------------------------------------------------------
/docs/en/api/utils.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.utils
5 | ===================================
6 |
7 | .. contents:: mmcv.utils
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.utils
13 |
14 | .. autosummary::
15 | :toctree: generated
16 | :nosignatures:
17 |
18 | IS_CUDA_AVAILABLE
19 | IS_MLU_AVAILABLE
20 | IS_MPS_AVAILABLE
21 | collect_env
22 | jit
23 | skip_no_elena
24 |
--------------------------------------------------------------------------------
/docs/en/api/video.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.video
5 | ===================================
6 |
7 | .. contents:: mmcv.video
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.video
13 |
14 | IO
15 | ----------------
16 |
17 | .. autosummary::
18 | :toctree: generated
19 | :nosignatures:
20 | :template: classtemplate.rst
21 |
22 | VideoReader
23 | Cache
24 |
25 | .. autosummary::
26 | :toctree: generated
27 | :nosignatures:
28 |
29 | frames2video
30 |
31 | Optical Flow
32 | ----------------
33 |
34 | .. autosummary::
35 | :toctree: generated
36 | :nosignatures:
37 |
38 | dequantize_flow
39 | flow_from_bytes
40 | flow_warp
41 | flowread
42 | flowwrite
43 | quantize_flow
44 | sparse_flow_from_bytes
45 |
46 | Video Processing
47 | ----------------
48 |
49 | .. autosummary::
50 | :toctree: generated
51 | :nosignatures:
52 |
53 | concat_video
54 | convert_video
55 | cut_video
56 | resize_video
57 |
--------------------------------------------------------------------------------
/docs/en/api/visualization.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.visualization
5 | ===================================
6 |
7 | .. contents:: mmcv.visualization
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.visualization
13 |
14 | Color
15 | ----------------
16 |
17 | .. autosummary::
18 | :toctree: generated
19 | :nosignatures:
20 | :template: classtemplate.rst
21 |
22 | Color
23 |
24 | .. autosummary::
25 | :toctree: generated
26 | :nosignatures:
27 |
28 | color_val
29 |
30 | Image
31 | ----------------
32 |
33 | .. autosummary::
34 | :toctree: generated
35 | :nosignatures:
36 |
37 | imshow
38 | imshow_bboxes
39 | imshow_det_bboxes
40 |
41 | Optical Flow
42 | ----------------
43 |
44 | .. autosummary::
45 | :toctree: generated
46 | :nosignatures:
47 |
48 | flow2rgb
49 | flowshow
50 | make_color_wheel
51 |
--------------------------------------------------------------------------------
/docs/en/community/pr.md:
--------------------------------------------------------------------------------
1 | ## Pull Request (PR)
2 |
3 | Content has been migrated to [contributing guidance](contributing.md).
4 |
--------------------------------------------------------------------------------
/docs/en/docutils.conf:
--------------------------------------------------------------------------------
1 | [html writers]
2 | table_style: colwidths-auto
3 |
--------------------------------------------------------------------------------
/docs/en/get_started/previous_versions.md:
--------------------------------------------------------------------------------
1 | ## OTHER VERSIONS OF PYTORCH BUILT FOR MMCV-FULL
2 |
3 | We no longer provide `mmcv-full` packages compiled under lower versions of `PyTorch`, but for your convenience, you can find them below.
4 |
5 | ### PyTorch 1.4
6 |
7 | | 1.0.0 \<= mmcv_version \<= 1.2.1
8 |
9 | #### CUDA 10.1
10 |
11 | ```bash
12 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.4.0/index.html
13 | ```
14 |
15 | #### CUDA 9.2
16 |
17 | ```bash
18 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.4.0/index.html
19 | ```
20 |
21 | #### CPU
22 |
23 | ```bash
24 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.4.0/index.html
25 | ```
26 |
27 | ### PyTorch v1.3
28 |
29 | | 1.0.0 \<= mmcv_version \<= 1.3.16
30 |
31 | #### CUDA 10.1
32 |
33 | ```bash
34 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.3.0/index.html
35 | ```
36 |
37 | #### CUDA 9.2
38 |
39 | ```bash
40 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.3.0/index.html
41 | ```
42 |
43 | #### CPU
44 |
45 | ```bash
46 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.3.0/index.html
47 | ```
48 |
--------------------------------------------------------------------------------
/docs/en/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SOURCEDIR=.
11 | set BUILDDIR=_build
12 |
13 | if "%1" == "" goto help
14 |
15 | %SPHINXBUILD% >NUL 2>NUL
16 | if errorlevel 9009 (
17 | echo.
18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19 | echo.installed, then set the SPHINXBUILD environment variable to point
20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
21 | echo.may add the Sphinx directory to PATH.
22 | echo.
23 | echo.If you don't have Sphinx installed, grab it from
24 | echo.http://sphinx-doc.org/
25 | exit /b 1
26 | )
27 |
28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
29 | goto end
30 |
31 | :help
32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
33 |
34 | :end
35 | popd
36 |
--------------------------------------------------------------------------------
/docs/en/mmcv-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/en/mmcv-logo.png
--------------------------------------------------------------------------------
/docs/en/switch_language.md:
--------------------------------------------------------------------------------
1 | ## English
2 |
3 | ## 简体中文
4 |
--------------------------------------------------------------------------------
/docs/en/understand_mmcv/visualization.md:
--------------------------------------------------------------------------------
1 | ## Visualization
2 |
3 | `mmcv` can show images and annotations (currently supported types include bounding boxes).
4 |
5 | ```python
6 | # show an image file
7 | mmcv.imshow('a.jpg')
8 |
9 | # show a loaded image
10 | img = np.random.rand(100, 100, 3)
11 | mmcv.imshow(img)
12 |
13 | # show image with bounding boxes
14 | img = np.random.rand(100, 100, 3)
15 | bboxes = np.array([[0, 0, 50, 50], [20, 20, 60, 60]])
16 | mmcv.imshow_bboxes(img, bboxes)
17 | ```
18 |
19 | `mmcv` can also visualize special images such as optical flows.
20 |
21 | ```python
22 | flow = mmcv.flowread('test.flo')
23 | mmcv.flowshow(flow)
24 | ```
25 |
--------------------------------------------------------------------------------
/docs/zh_cn/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SOURCEDIR = .
8 | BUILDDIR = _build
9 |
10 | # Put it first so that "make" without argument is like "make help".
11 | help:
12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13 |
14 | .PHONY: help Makefile
15 |
16 | # Catch-all target: route all unknown targets to Sphinx using the new
17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
18 | %: Makefile
19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20 |
--------------------------------------------------------------------------------
/docs/zh_cn/_static/css/readthedocs.css:
--------------------------------------------------------------------------------
1 | .header-logo {
2 | background-image: url("../image/mmcv-logo.png");
3 | background-size: 85px 40px;
4 | height: 40px;
5 | width: 85px;
6 | }
7 |
8 | table.colwidths-auto td {
9 | width: 50%
10 | }
11 |
--------------------------------------------------------------------------------
/docs/zh_cn/_static/image/mmcv-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/docs/zh_cn/_static/image/mmcv-logo.png
--------------------------------------------------------------------------------
/docs/zh_cn/_templates/classtemplate.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 | .. currentmodule:: {{ module }}
4 |
5 |
6 | {{ name | underline}}
7 |
8 | .. autoclass:: {{ name }}
9 | :members:
10 |
11 |
12 | ..
13 | autogenerated from source/_templates/classtemplate.rst
14 | note it does not have :inherited-members:
15 |
--------------------------------------------------------------------------------
/docs/zh_cn/api/arraymisc.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.arraymisc
5 | ===================================
6 |
7 | .. contents:: mmcv.arraymisc
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.arraymisc
13 |
14 | .. autosummary::
15 | :toctree: generated
16 | :nosignatures:
17 |
18 | quantize
19 | dequantize
20 |
--------------------------------------------------------------------------------
/docs/zh_cn/api/cnn.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.cnn
5 | ===================================
6 |
7 | .. contents:: mmcv.cnn
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.cnn
13 |
14 | Module
15 | ----------------
16 |
17 | .. autosummary::
18 | :toctree: generated
19 | :nosignatures:
20 | :template: classtemplate.rst
21 |
22 | ContextBlock
23 | Conv2d
24 | Conv3d
25 | ConvAWS2d
26 | ConvModule
27 | ConvTranspose2d
28 | ConvTranspose3d
29 | ConvWS2d
30 | DepthwiseSeparableConvModule
31 | GeneralizedAttention
32 | HSigmoid
33 | HSwish
34 | LayerScale
35 | Linear
36 | MaxPool2d
37 | MaxPool3d
38 | NonLocal1d
39 | NonLocal2d
40 | NonLocal3d
41 | Scale
42 | Swish
43 | Conv2dRFSearchOp
44 |
45 | Build Function
46 | ----------------
47 |
48 | .. autosummary::
49 | :toctree: generated
50 | :nosignatures:
51 |
52 | build_activation_layer
53 | build_conv_layer
54 | build_norm_layer
55 | build_padding_layer
56 | build_plugin_layer
57 | build_upsample_layer
58 |
59 | Miscellaneous
60 | ----------------
61 |
62 | .. autosummary::
63 | :toctree: generated
64 | :nosignatures:
65 |
66 | fuse_conv_bn
67 | conv_ws_2d
68 | is_norm
69 | make_res_layer
70 | make_vgg_layer
71 | get_model_complexity_info
72 |
--------------------------------------------------------------------------------
/docs/zh_cn/api/transforms.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.transforms
5 | ===================================
6 |
7 | .. currentmodule:: mmcv.transforms
8 |
9 | .. autosummary::
10 | :toctree: generated
11 | :nosignatures:
12 | :template: classtemplate.rst
13 |
14 | BaseTransform
15 | TestTimeAug
16 |
17 | Loading
18 | ----------------
19 |
20 | .. autosummary::
21 | :toctree: generated
22 | :nosignatures:
23 | :template: classtemplate.rst
24 |
25 | LoadAnnotations
26 | LoadImageFromFile
27 |
28 | Processing
29 | ----------------
30 |
31 | .. autosummary::
32 | :toctree: generated
33 | :nosignatures:
34 | :template: classtemplate.rst
35 |
36 | CenterCrop
37 | MultiScaleFlipAug
38 | Normalize
39 | Pad
40 | RandomChoiceResize
41 | RandomFlip
42 | RandomGrayscale
43 | RandomResize
44 | Resize
45 | ToTensor
46 | ImageToTensor
47 |
48 | Wrapper
49 | ----------------
50 |
51 | .. autosummary::
52 | :toctree: generated
53 | :nosignatures:
54 | :template: classtemplate.rst
55 |
56 | Compose
57 | KeyMapper
58 | RandomApply
59 | RandomChoice
60 | TransformBroadcaster
61 |
--------------------------------------------------------------------------------
/docs/zh_cn/api/utils.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.utils
5 | ===================================
6 |
7 | .. contents:: mmcv.utils
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.utils
13 |
14 | .. autosummary::
15 | :toctree: generated
16 | :nosignatures:
17 |
18 | IS_CUDA_AVAILABLE
19 | IS_MLU_AVAILABLE
20 | IS_MPS_AVAILABLE
21 | collect_env
22 | jit
23 | skip_no_elena
24 |
--------------------------------------------------------------------------------
/docs/zh_cn/api/video.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.video
5 | ===================================
6 |
7 | .. contents:: mmcv.video
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.video
13 |
14 | IO
15 | ----------------
16 |
17 | .. autosummary::
18 | :toctree: generated
19 | :nosignatures:
20 | :template: classtemplate.rst
21 |
22 | VideoReader
23 | Cache
24 |
25 | .. autosummary::
26 | :toctree: generated
27 | :nosignatures:
28 |
29 | frames2video
30 |
31 | Optical Flow
32 | ----------------
33 |
34 | .. autosummary::
35 | :toctree: generated
36 | :nosignatures:
37 |
38 | dequantize_flow
39 | flow_from_bytes
40 | flow_warp
41 | flowread
42 | flowwrite
43 | quantize_flow
44 | sparse_flow_from_bytes
45 |
46 | Video Processing
47 | ----------------
48 |
49 | .. autosummary::
50 | :toctree: generated
51 | :nosignatures:
52 |
53 | concat_video
54 | convert_video
55 | cut_video
56 | resize_video
57 |
--------------------------------------------------------------------------------
/docs/zh_cn/api/visualization.rst:
--------------------------------------------------------------------------------
1 | .. role:: hidden
2 | :class: hidden-section
3 |
4 | mmcv.visualization
5 | ===================================
6 |
7 | .. contents:: mmcv.visualization
8 | :depth: 2
9 | :local:
10 | :backlinks: top
11 |
12 | .. currentmodule:: mmcv.visualization
13 |
14 | Color
15 | ----------------
16 |
17 | .. autosummary::
18 | :toctree: generated
19 | :nosignatures:
20 | :template: classtemplate.rst
21 |
22 | Color
23 |
24 | .. autosummary::
25 | :toctree: generated
26 | :nosignatures:
27 |
28 | color_val
29 |
30 | Image
31 | ----------------
32 |
33 | .. autosummary::
34 | :toctree: generated
35 | :nosignatures:
36 |
37 | imshow
38 | imshow_bboxes
39 | imshow_det_bboxes
40 |
41 | Optical Flow
42 | ----------------
43 |
44 | .. autosummary::
45 | :toctree: generated
46 | :nosignatures:
47 |
48 | flow2rgb
49 | flowshow
50 | make_color_wheel
51 |
--------------------------------------------------------------------------------
/docs/zh_cn/community/pr.md:
--------------------------------------------------------------------------------
1 | ## 拉取请求
2 |
3 | 本文档的内容已迁移到[贡献指南](contributing.md)。
4 |
--------------------------------------------------------------------------------
/docs/zh_cn/docutils.conf:
--------------------------------------------------------------------------------
1 | [html writers]
2 | table_style: colwidths-auto
3 |
--------------------------------------------------------------------------------
/docs/zh_cn/get_started/previous_versions.md:
--------------------------------------------------------------------------------
1 | ## 其他版本的 PyTorch
2 |
3 | 我们不再提供在较低的 `PyTorch` 版本下编译的 `mmcv-full` 包,但为了您的方便,您可以在下面找到它们。
4 |
5 | ### PyTorch 1.4
6 |
7 | | 1.0.0 \<= mmcv_version \<= 1.2.1
8 |
9 | #### CUDA 10.1
10 |
11 | ```bash
12 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.4.0/index.html
13 | ```
14 |
15 | #### CUDA 9.2
16 |
17 | ```bash
18 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.4.0/index.html
19 | ```
20 |
21 | #### CPU
22 |
23 | ```bash
24 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.4.0/index.html
25 | ```
26 |
27 | ### PyTorch v1.3
28 |
29 | | 1.0.0 \<= mmcv_version \<= 1.3.16
30 |
31 | #### CUDA 10.1
32 |
33 | ```bash
34 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.3.0/index.html
35 | ```
36 |
37 | #### CUDA 9.2
38 |
39 | ```bash
40 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.3.0/index.html
41 | ```
42 |
43 | #### CPU
44 |
45 | ```bash
46 | pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.3.0/index.html
47 | ```
48 |
--------------------------------------------------------------------------------
/docs/zh_cn/index.rst:
--------------------------------------------------------------------------------
1 | 欢迎来到 MMCV 的中文文档!
2 | =============================
3 |
4 | 您可以在页面左下角切换中英文文档。
5 |
6 | .. toctree::
7 | :maxdepth: 2
8 | :caption: 介绍与安装
9 |
10 | get_started/introduction.md
11 | get_started/installation.md
12 | get_started/build.md
13 | get_started/article.md
14 | get_started/api_reference.md
15 |
16 | .. toctree::
17 | :maxdepth: 2
18 | :caption: 深入理解 MMCV
19 |
20 | understand_mmcv/data_process.md
21 | understand_mmcv/data_transform.md
22 | understand_mmcv/visualization.md
23 | understand_mmcv/cnn.md
24 | understand_mmcv/ops.md
25 |
26 | .. toctree::
27 | :caption: 语言切换
28 |
29 | switch_language.md
30 |
31 | .. toctree::
32 | :maxdepth: 2
33 | :caption: 兼容性
34 |
35 | compatibility.md
36 |
37 | .. toctree::
38 |
39 | faq.md
40 |
41 | .. toctree::
42 | :maxdepth: 2
43 | :caption: 社区
44 |
45 | community/contributing.md
46 | community/pr.md
47 | community/code_style.md
48 |
49 | .. toctree::
50 | :maxdepth: 1
51 | :caption: API 文档
52 |
53 | mmcv.image
54 | mmcv.video
55 | mmcv.visualization
56 | mmcv.cnn
57 | mmcv.ops
58 | mmcv.transforms
59 | mmcv.arraymisc
60 | mmcv.utils
61 |
62 |
63 | Indices and tables
64 | ==================
65 |
66 | * :ref:`genindex`
67 | * :ref:`search`
68 |
--------------------------------------------------------------------------------
/docs/zh_cn/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SOURCEDIR=.
11 | set BUILDDIR=_build
12 |
13 | if "%1" == "" goto help
14 |
15 | %SPHINXBUILD% >NUL 2>NUL
16 | if errorlevel 9009 (
17 | echo.
18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19 | echo.installed, then set the SPHINXBUILD environment variable to point
20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
21 | echo.may add the Sphinx directory to PATH.
22 | echo.
23 | echo.If you don't have Sphinx installed, grab it from
24 | echo.http://sphinx-doc.org/
25 | exit /b 1
26 | )
27 |
28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
29 | goto end
30 |
31 | :help
32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
33 |
34 | :end
35 | popd
36 |
--------------------------------------------------------------------------------
/docs/zh_cn/mmcv-logo.png:
--------------------------------------------------------------------------------
1 | ../docs/mmcv-logo.png
--------------------------------------------------------------------------------
/docs/zh_cn/switch_language.md:
--------------------------------------------------------------------------------
1 | ## English
2 |
3 | ## 简体中文
4 |
--------------------------------------------------------------------------------
/docs/zh_cn/understand_mmcv/visualization.md:
--------------------------------------------------------------------------------
1 | ## 可视化
2 |
3 | `mmcv` 可以展示图像以及标注(目前只支持标注框)
4 |
5 | ```python
6 | # 展示图像文件
7 | mmcv.imshow('a.jpg')
8 |
9 | # 展示已加载的图像
10 | img = np.random.rand(100, 100, 3)
11 | mmcv.imshow(img)
12 |
13 | # 展示带有标注框的图像
14 | img = np.random.rand(100, 100, 3)
15 | bboxes = np.array([[0, 0, 50, 50], [20, 20, 60, 60]])
16 | mmcv.imshow_bboxes(img, bboxes)
17 | ```
18 |
19 | `mmcv` 也可以展示特殊的图像,例如光流
20 |
21 | ```python
22 | flow = mmcv.flowread('test.flo')
23 | mmcv.flowshow(flow)
24 | ```
25 |
--------------------------------------------------------------------------------
/mmcv/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | # flake8: noqa
3 | from .arraymisc import *
4 | from .image import *
5 | from .transforms import *
6 | from .version import *
7 | from .video import *
8 | from .visualization import *
9 |
10 | # The following modules are not imported to this level, so mmcv may be used
11 | # without PyTorch.
12 | # - op
13 | # - utils
14 |
--------------------------------------------------------------------------------
/mmcv/arraymisc/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from .quantization import dequantize, quantize
3 |
4 | __all__ = ['quantize', 'dequantize']
5 |
--------------------------------------------------------------------------------
/mmcv/cnn/bricks/hswish.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 | import torch.nn as nn
4 | from mmengine.registry import MODELS
5 | from mmengine.utils import digit_version
6 | from mmengine.utils.dl_utils import TORCH_VERSION
7 |
8 |
9 | class HSwish(nn.Module):
10 | """Hard Swish Module.
11 |
12 | This module applies the hard swish function:
13 |
14 | .. math::
15 | Hswish(x) = x * ReLU6(x + 3) / 6
16 |
17 | Args:
18 | inplace (bool): can optionally do the operation in-place.
19 | Default: False.
20 |
21 | Returns:
22 | Tensor: The output tensor.
23 | """
24 |
25 | def __init__(self, inplace: bool = False):
26 | super().__init__()
27 | self.act = nn.ReLU6(inplace)
28 |
29 | def forward(self, x: torch.Tensor) -> torch.Tensor:
30 | return x * self.act(x + 3) / 6
31 |
32 |
33 | if (TORCH_VERSION == 'parrots'
34 | or digit_version(TORCH_VERSION) < digit_version('1.7')):
35 | # Hardswish is not supported when PyTorch version < 1.6.
36 | # And Hardswish in PyTorch 1.6 does not support inplace.
37 | MODELS.register_module(module=HSwish)
38 | else:
39 | MODELS.register_module(module=nn.Hardswish, name='HSwish')
40 |
--------------------------------------------------------------------------------
/mmcv/cnn/bricks/swish.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 | import torch.nn as nn
4 | from mmengine.registry import MODELS
5 |
6 |
7 | @MODELS.register_module()
8 | class Swish(nn.Module):
9 | """Swish Module.
10 |
11 | This module applies the swish function:
12 |
13 | .. math::
14 | Swish(x) = x * Sigmoid(x)
15 |
16 | Returns:
17 | Tensor: The output tensor.
18 | """
19 |
20 | def __init__(self):
21 | super().__init__()
22 |
23 | def forward(self, x: torch.Tensor) -> torch.Tensor:
24 | return x * torch.sigmoid(x)
25 |
--------------------------------------------------------------------------------
/mmcv/cnn/rfsearch/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from .operator import BaseConvRFSearchOp, Conv2dRFSearchOp
3 | from .search import RFSearchHook
4 |
5 | __all__ = ['BaseConvRFSearchOp', 'Conv2dRFSearchOp', 'RFSearchHook']
6 |
--------------------------------------------------------------------------------
/mmcv/cnn/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from .flops_counter import get_model_complexity_info
3 | from .fuse_conv_bn import fuse_conv_bn
4 |
5 | __all__ = ['get_model_complexity_info', 'fuse_conv_bn']
6 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp:
--------------------------------------------------------------------------------
1 | #ifndef PYTORCH_CPP_HELPER
2 | #define PYTORCH_CPP_HELPER
3 | #include
4 |
5 | #include
6 |
7 | using namespace at;
8 |
9 | #define CHECK_CUDA(x) \
10 | TORCH_CHECK(x.device().is_cuda(), #x " must be a CUDA tensor")
11 | #define CHECK_MLU(x) \
12 | TORCH_CHECK(x.device().type() == at::kMLU, #x " must be a MLU tensor")
13 | #define CHECK_MUSA(x) \
14 | TORCH_CHECK(x.device().is_privateuseone(), #x " must be a MUSA tensor")
15 | #define CHECK_CPU(x) \
16 | TORCH_CHECK(x.device().type() == at::kCPU, #x " must be a CPU tensor")
17 | #define CHECK_CONTIGUOUS(x) \
18 | TORCH_CHECK(x.is_contiguous(), #x " must be contiguous")
19 | #define CHECK_CUDA_INPUT(x) \
20 | CHECK_CUDA(x); \
21 | CHECK_CONTIGUOUS(x)
22 | #define CHECK_MLU_INPUT(x) \
23 | CHECK_MLU(x); \
24 | CHECK_CONTIGUOUS(x)
25 | #define CHECK_MUSA_INPUT(x) \
26 | CHECK_MUSA(x); \
27 | CHECK_CONTIGUOUS(x)
28 | #define CHECK_CPU_INPUT(x) \
29 | CHECK_CPU(x); \
30 | CHECK_CONTIGUOUS(x)
31 |
32 | #endif // PYTORCH_CPP_HELPER
33 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/common/pytorch_cuda_helper.hpp:
--------------------------------------------------------------------------------
1 | #ifndef PYTORCH_CUDA_HELPER
2 | #define PYTORCH_CUDA_HELPER
3 |
4 | #include
5 | #ifdef MMCV_WITH_MUSA
6 | #include "common_musa_helper.hpp"
7 | #include "torch_musa/csrc/aten/musa/MUSAContext.h"
8 | #include "torch_musa/csrc/core/MUSAGuard.h"
9 | #include "torch_musa/share/generated_cuda_compatible/aten/src/THC/THCAtomics.muh"
10 | #include "torch_musa/share/generated_cuda_compatible/include/ATen/musa/MUSA_PORT_ApplyUtils.muh"
11 | #else
12 | #include
13 | #include
14 |
15 | #include
16 | #include
17 |
18 | #include "common_cuda_helper.hpp"
19 | #endif
20 |
21 | using at::Half;
22 | using at::Tensor;
23 | using phalf = at::Half;
24 |
25 | #define __PHALF(x) (x)
26 | #define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0))
27 |
28 | #endif // PYTORCH_CUDA_HELPER
29 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/common/pytorch_musa_helper.hpp:
--------------------------------------------------------------------------------
1 | #ifndef PYTORCH_MUSA_HELPER
2 | #define PYTORCH_MUSA_HELPER
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | #include "common_musa_helper.hpp"
10 | #include "torch_musa/csrc/aten/musa/Exceptions.h"
11 | #include "torch_musa/csrc/aten/musa/MUSAContext.h"
12 | #include "torch_musa/csrc/core/MUSAGuard.h"
13 |
14 | using at::Half;
15 | using at::Tensor;
16 | using phalf = at::Half;
17 |
18 | #define __PHALF(x) (x)
19 | #define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0))
20 |
21 | #endif // PYTORCH_CUDA_HELPER
22 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/common/utils/spconv/spconv/mp_helper.h:
--------------------------------------------------------------------------------
1 | #ifndef MP_HELPER_H_
2 | #define MP_HELPER_H_
3 | #include
4 | #include
5 |
6 | template
7 | struct mp_list {};
8 |
9 | template
10 | using mp_list_c = mp_list...>;
11 |
12 | namespace detail {
13 |
14 | template
15 | constexpr F mp_for_each_impl(mp_list, F &&f) {
16 | return std::initializer_list{(f(T()), 0)...}, std::forward(f);
17 | }
18 |
19 | template
20 | constexpr F mp_for_each_impl(mp_list<>, F &&f) {
21 | return std::forward(f);
22 | }
23 |
24 | } // namespace detail
25 |
26 | namespace detail {
27 |
28 | template class B>
29 | struct mp_rename_impl {
30 | // An error "no type named 'type'" here means that the first argument to
31 | // mp_rename is not a list
32 | };
33 |
34 | template class A, class... T, template class B>
35 | struct mp_rename_impl, B> {
36 | using type = B;
37 | };
38 |
39 | } // namespace detail
40 |
41 | template class B>
42 | using mp_rename = typename ::detail::mp_rename_impl::type;
43 |
44 | template
45 | constexpr F mp_for_each(F &&f) {
46 | return ::detail::mp_for_each_impl(mp_rename(),
47 | std::forward(f));
48 | }
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/common/utils/spconv/spconv/reordering.h:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Yan Yan
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef SPARSE_REORDERING_FUNCTOR_H_
16 | #define SPARSE_REORDERING_FUNCTOR_H_
17 | #include
18 |
19 | namespace functor {
20 | template
21 | struct SparseGatherFunctor {
22 | void operator()(const Device& d, tv::TensorView buffer,
23 | tv::TensorView features,
24 | tv::TensorView indices, int size);
25 | };
26 |
27 | template
28 | struct SparseScatterAddFunctor {
29 | void operator()(const Device& d, tv::TensorView out_features,
30 | tv::TensorView buffer,
31 | tv::TensorView indices, int size,
32 | bool stable = false);
33 | };
34 | } // namespace functor
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/common/utils/spconv/tensorview/helper_launch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | // from pytorch.aten
3 | #include "tensorview.h"
4 | namespace tv {
5 | namespace launch {
6 |
7 | template
8 | inline int DivUp(const T1 a, const T2 b) {
9 | return (a + b - 1) / b;
10 | }
11 |
12 | constexpr int CUDA_NUM_THREADS = 1024;
13 | constexpr int MUSA_NUM_THREADS = 1024;
14 | inline int getBlocks(const int N) {
15 | TV_ASSERT_RT_ERR(N > 0,
16 | "CUDA kernel launch blocks must be positive, but got N=", N);
17 | return DivUp(N, CUDA_NUM_THREADS);
18 | }
19 | } // namespace launch
20 | } // namespace tv
21 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/active_rotated_filter.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved.
2 | // Modified from
3 | // https://github.com/csuhan/s2anet/blob/master/mmdet/ops/orn/src/ActiveRotatingFilter.h
4 |
5 | #include "pytorch_cpp_helper.hpp"
6 | #include "pytorch_device_registry.hpp"
7 |
8 | void active_rotated_filter_forward_impl(const Tensor input,
9 | const Tensor indices, Tensor output) {
10 | DISPATCH_DEVICE_IMPL(active_rotated_filter_forward_impl, input, indices,
11 | output);
12 | }
13 |
14 | void active_rotated_filter_backward_impl(const Tensor grad_out,
15 | const Tensor indices, Tensor grad_in) {
16 | DISPATCH_DEVICE_IMPL(active_rotated_filter_backward_impl, grad_out, indices,
17 | grad_in);
18 | }
19 |
20 | void active_rotated_filter_forward(const Tensor input, const Tensor indices,
21 | Tensor output) {
22 | active_rotated_filter_forward_impl(input, indices, output);
23 | }
24 |
25 | void active_rotated_filter_backward(const Tensor grad_out, const Tensor indices,
26 | Tensor grad_in) {
27 | active_rotated_filter_backward_impl(grad_out, indices, grad_in);
28 | }
29 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/active_rotated_filter_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef ACTIVE_ROTATED_FILTER_PYTORCH_H
3 | #define ACTIVE_ROTATED_FILTER_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void active_rotated_filter_forward(const Tensor input, const Tensor indices,
8 | Tensor output);
9 |
10 | void active_rotated_filter_backward(const Tensor grad_out, const Tensor indices,
11 | Tensor grad_in);
12 |
13 | #endif // ACTIVE_ROTATED_FILTER_PYTORCH_H
14 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/assign_score_withk_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef ASSIGN_SCORE_WITHK_PYTORCH_H
3 | #define ASSIGN_SCORE_WITHK_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void assign_score_withk_forward(const Tensor& points, const Tensor& centers,
8 | const Tensor& scores, const Tensor& knn_idx,
9 | Tensor& output, int B, int N0, int N1, int M,
10 | int K, int O, int aggregate);
11 |
12 | void assign_score_withk_backward(const Tensor& grad_out, const Tensor& points,
13 | const Tensor& centers, const Tensor& scores,
14 | const Tensor& knn_idx, Tensor& grad_points,
15 | Tensor& grad_centers, Tensor& grad_scores,
16 | int B, int N0, int N1, int M, int K, int O,
17 | int aggregate);
18 |
19 | #endif // ASSIGN_SCORE_WITHK_PYTORCH_H
20 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/ball_query._parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "ball_query_pytorch.h"
7 |
8 | using namespace parrots;
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | void ball_query_parrots(CudaContext& ctx, const SSElement& attr,
12 | const OperatorBase::in_list_t& ins,
13 | OperatorBase::out_list_t& outs) {
14 | int b, n, m, nsample;
15 | float min_radius, max_radius;
16 | SSAttrs(attr)
17 | .get("b", b)
18 | .get("n", n)
19 | .get("m", m)
20 | .get("nsample", nsample)
21 | .get("min_radius", min_radius)
22 | .get("max_radius", max_radius)
23 | .done();
24 |
25 | const auto& center_xyz = buildATensor(ctx, ins[0]);
26 | const auto& xyz = buildATensor(ctx, ins[1]);
27 | auto idx = buildATensor(ctx, outs[0]);
28 | ball_query_forward(center_xyz, xyz, idx, b, n, m, min_radius, max_radius,
29 | nsample);
30 | }
31 |
32 | PARROTS_EXTENSION_REGISTER(ball_query_forward)
33 | .attr("b")
34 | .attr("n")
35 | .attr("m")
36 | .attr("nsample")
37 | .attr("min_radius")
38 | .attr("max_radius")
39 | .input(2)
40 | .output(1)
41 | .apply(ball_query_parrots)
42 | .done();
43 | #endif
44 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/ball_query.cpp:
--------------------------------------------------------------------------------
1 | // Modified from
2 | // https://github.com/sshaoshuai/Pointnet2.PyTorch/tree/master/pointnet2/src/ball_query.cpp
3 |
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void ball_query_forward_impl(int b, int n, int m, float min_radius,
8 | float max_radius, int nsample,
9 | const Tensor new_xyz, const Tensor xyz,
10 | Tensor idx) {
11 | DISPATCH_DEVICE_IMPL(ball_query_forward_impl, b, n, m, min_radius, max_radius,
12 | nsample, new_xyz, xyz, idx);
13 | }
14 |
15 | void ball_query_forward(Tensor new_xyz_tensor, Tensor xyz_tensor,
16 | Tensor idx_tensor, int b, int n, int m,
17 | float min_radius, float max_radius, int nsample) {
18 | ball_query_forward_impl(b, n, m, min_radius, max_radius, nsample,
19 | new_xyz_tensor, xyz_tensor, idx_tensor);
20 | }
21 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/ball_query_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef BALL_QUERY_PYTORCH_H
3 | #define BALL_QUERY_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void ball_query_forward(const Tensor new_xyz, const Tensor xyz, Tensor idx,
8 | int b, int n, int m, float min_radius, float max_radius,
9 | int nsample);
10 |
11 | #endif // BALL_QUERY_PYTORCH_H
12 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/bbox_overlaps.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | void bbox_overlaps_impl(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
6 | const int mode, const bool aligned, const int offset) {
7 | DISPATCH_DEVICE_IMPL(bbox_overlaps_impl, bboxes1, bboxes2, ious, mode,
8 | aligned, offset);
9 | }
10 |
11 | void bbox_overlaps(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
12 | const int mode, const bool aligned, const int offset) {
13 | bbox_overlaps_impl(bboxes1, bboxes2, ious, mode, aligned, offset);
14 | }
15 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/bbox_overlaps_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "bbox_overlaps_pytorch.h"
7 |
8 | using namespace parrots;
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | /*
12 | * void bbox_overlaps_cuda(const Tensor bboxes1, const Tensor bboxes2, Tensor
13 | * ious, const int mode, const bool aligned, const int offset);
14 | */
15 | void bbox_overlaps_parrots(CudaContext& ctx, const SSElement& attr,
16 | const OperatorBase::in_list_t& ins,
17 | OperatorBase::out_list_t& outs) {
18 | int mode, offset;
19 | bool aligned;
20 | SSAttrs(attr)
21 | .get("mode", mode)
22 | .get("aligned", aligned)
23 | .get("offset", offset)
24 | .done();
25 |
26 | const auto& bboxes1 = buildATensor(ctx, ins[0]);
27 | const auto& bboxes2 = buildATensor(ctx, ins[1]);
28 | auto ious = buildATensor(ctx, outs[0]);
29 | bbox_overlaps_cuda(bboxes1, bboxes2, ious, mode, aligned, offset);
30 | }
31 |
32 | PARROTS_EXTENSION_REGISTER(bbox_overlaps)
33 | .attr("mode")
34 | .attr("aligned")
35 | .attr("offset")
36 | .input(2)
37 | .output(1)
38 | .apply(bbox_overlaps_parrots)
39 | .done();
40 | #endif
41 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/bbox_overlaps_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef BBOX_OVERLAPS_PYTORCH_H
3 | #define BBOX_OVERLAPS_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void bbox_overlaps_cuda(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
8 | const int mode, const bool aligned, const int offset);
9 |
10 | #endif // BBOX_OVERLAPS_PYTORCH_H
11 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/border_align.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | void border_align_forward_impl(const Tensor &input, const Tensor &boxes,
6 | Tensor output, Tensor argmax_idx,
7 | const int pool_size) {
8 | DISPATCH_DEVICE_IMPL(border_align_forward_impl, input, boxes, output,
9 | argmax_idx, pool_size);
10 | }
11 |
12 | void border_align_backward_impl(const Tensor &grad_output, const Tensor &boxes,
13 | const Tensor &argmax_idx, Tensor grad_input,
14 | const int pool_size) {
15 | DISPATCH_DEVICE_IMPL(border_align_backward_impl, grad_output, boxes,
16 | argmax_idx, grad_input, pool_size);
17 | }
18 |
19 | void border_align_forward(const Tensor &input, const Tensor &boxes,
20 | Tensor output, Tensor argmax_idx,
21 | const int pool_size) {
22 | border_align_forward_impl(input, boxes, output, argmax_idx, pool_size);
23 | }
24 |
25 | void border_align_backward(const Tensor &grad_output, const Tensor &boxes,
26 | const Tensor &argmax_idx, Tensor grad_input,
27 | const int pool_size) {
28 | border_align_backward_impl(grad_output, boxes, argmax_idx, grad_input,
29 | pool_size);
30 | }
31 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/border_align_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef BORDER_ALIGN_PYTORCH_H
3 | #define BORDER_ALIGN_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | #ifdef MMCV_WITH_CUDA
8 | void border_align_forward_cuda(const Tensor &input, const Tensor &boxes,
9 | Tensor output, Tensor argmax_idx,
10 | const int pool_size);
11 |
12 | void border_align_backward_cuda(const Tensor &grad_output, const Tensor &boxes,
13 | const Tensor &argmax_idx, Tensor grad_input,
14 | const int pool_size);
15 | #endif
16 |
17 | #endif // BORDER_ALIGN_PYTORCH_H
18 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/box_iou_rotated.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | // modified from
3 | // https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void box_iou_rotated_impl(const Tensor boxes1, const Tensor boxes2, Tensor ious,
8 | const int mode_flag, const bool aligned) {
9 | DISPATCH_DEVICE_IMPL(box_iou_rotated_impl, boxes1, boxes2, ious, mode_flag,
10 | aligned);
11 | }
12 |
13 | // Interface for Python
14 | // inline is needed to prevent multiple function definitions when this header is
15 | // included by different cpps
16 | void box_iou_rotated(const Tensor boxes1, const Tensor boxes2, Tensor ious,
17 | const int mode_flag, const bool aligned) {
18 | box_iou_rotated_impl(boxes1, boxes2, ious, mode_flag, aligned);
19 | }
20 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/box_iou_rotated_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef BOX_IOU_ROTATED_PYTORCH_H
3 | #define BOX_IOU_ROTATED_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void box_iou_rotated_cpu(const Tensor boxes1, const Tensor boxes2, Tensor ious,
8 | const int mode_flag, const bool aligned);
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | void box_iou_rotated_cuda(const Tensor boxes1, const Tensor boxes2, Tensor ious,
12 | const int mode_flag, const bool aligned);
13 | #endif
14 |
15 | #endif // BOX_IOU_ROTATED_PYTORCH_H
16 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/carafe_naive_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef CARAFE_NAIVE_PYTORCH_H
3 | #define CARAFE_NAIVE_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void carafe_naive_forward_cuda(Tensor features, Tensor masks, Tensor output,
8 | int kernel_size, int group_size,
9 | int scale_factor);
10 |
11 | void carafe_naive_backward_cuda(Tensor top_grad, Tensor features, Tensor masks,
12 | Tensor bottom_grad, Tensor mask_grad,
13 | int kernel_size, int group_size,
14 | int scale_factor);
15 | #endif // CARAFE_NAIVE_PYTORCH_H
16 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/carafe_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef CARAFE_PYTORCH_H
3 | #define CARAFE_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void carafe_forward_cuda(Tensor features, Tensor masks, Tensor rfeatures,
8 | Tensor routput, Tensor rmasks, Tensor output,
9 | int kernel_size, int group_size, int scale_factor);
10 |
11 | void carafe_backward_cuda(Tensor top_grad, Tensor rfeatures, Tensor masks,
12 | Tensor rtop_grad, Tensor rbottom_grad_hs,
13 | Tensor rbottom_grad, Tensor rmask_grad,
14 | Tensor bottom_grad, Tensor mask_grad, int kernel_size,
15 | int group_size, int scale_factor);
16 | #endif // CARAFE_PYTORCH_H
17 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/chamfer_distance_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef ACTIVE_CHAMFER_DISTANCE_PYTORCH_H
3 | #define ACTIVE_CHAMFER_DISTANCE_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void chamfer_distance_forward(const Tensor xyz1, const Tensor xyz2,
8 | const Tensor dist1, const Tensor dist2,
9 | const Tensor idx1, const Tensor idx);
10 |
11 | void chamfer_distance_backward(const Tensor xyz1, const Tensor xyz2,
12 | Tensor idx1, Tensor idx2, Tensor graddist1,
13 | Tensor graddist2, Tensor gradxyz1,
14 | Tensor gradxyz2);
15 |
16 | #endif // ACTIVE_CHAMFER_DISTANCE_PYTORCH_H
17 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/contour_expand_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef CONTOUR_EXPAND_PYTORCH_H
3 | #define CONTOUR_EXPAND_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | std::vector> contour_expand(Tensor kernel_mask,
8 | Tensor internal_kernel_label,
9 | int min_kernel_area,
10 | int kernel_num);
11 |
12 | #endif // CONTOUR_EXPAND_PYTORCH_H
13 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/convex_iou.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // modified from
3 | // https://github.com/SDL-GuoZonghao/BeyondBoundingBox/tree/main/mmdet/ops/iou/src
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void convex_iou_impl(const Tensor pointsets, const Tensor polygons,
8 | Tensor ious) {
9 | DISPATCH_DEVICE_IMPL(convex_iou_impl, pointsets, polygons, ious);
10 | }
11 |
12 | void convex_iou(const Tensor pointsets, const Tensor polygons, Tensor ious) {
13 | convex_iou_impl(pointsets, polygons, ious);
14 | }
15 |
16 | void convex_giou_impl(const Tensor pointsets, const Tensor polygons,
17 | Tensor output) {
18 | DISPATCH_DEVICE_IMPL(convex_giou_impl, pointsets, polygons, output);
19 | }
20 |
21 | void convex_giou(const Tensor pointsets, const Tensor polygons, Tensor output) {
22 | convex_giou_impl(pointsets, polygons, output);
23 | }
24 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/convex_iou_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "convex_iou_pytorch.h"
7 | using namespace parrots;
8 |
9 | #ifdef MMCV_WITH_CUDA
10 | void convex_iou_forward_cuda_parrots(CudaContext& ctx, const SSElement& attr,
11 | const OperatorBase::in_list_t& ins,
12 | OperatorBase::out_list_t& outs) {
13 | auto pointsets = buildATensor(ctx, ins[0]);
14 | auto polygons = buildATensor(ctx, ins[1]);
15 | auto ious = buildATensor(ctx, outs[0]);
16 | convex_iou(pointsets, polygons, ious);
17 | }
18 |
19 | void convex_giou_forward_cuda_parrots(CudaContext& ctx, const SSElement& attr,
20 | const OperatorBase::in_list_t& ins,
21 | OperatorBase::out_list_t& outs) {
22 | auto pointsets = buildATensor(ctx, ins[0]);
23 | auto polygons = buildATensor(ctx, ins[1]);
24 | auto output = buildATensor(ctx, outs[0]);
25 | convex_giou(pointsets, polygons, output);
26 | }
27 |
28 | PARROTS_EXTENSION_REGISTER(convex_iou)
29 | .input(2)
30 | .output(1)
31 | .apply(convex_iou_forward_cuda_parrots)
32 | .done();
33 |
34 | PARROTS_EXTENSION_REGISTER(convex_giou)
35 | .input(2)
36 | .output(1)
37 | .apply(convex_giou_forward_cuda_parrots)
38 | .done();
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/convex_iou_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef CONVEX_IOU_PYTORCH_H
3 | #define CONVEX_IOU_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void convex_iou(const Tensor pointsets, const Tensor polygons, Tensor ious);
8 |
9 | void convex_giou(const Tensor pointsets, const Tensor polygons, Tensor output);
10 |
11 | #endif // RIROI_ALIGN_ROTATED_PYTORCH_H
12 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/correlation_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef CORRELATION_PYTORCH_H
3 | #define CORRELATION_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void correlation_forward(Tensor input1, Tensor input2, Tensor output, int kH,
8 | int kW, int patchH, int patchW, int padH, int padW,
9 | int dilationH, int dilationW, int dilation_patchH,
10 | int dilation_patchW, int dH, int dW);
11 |
12 | void correlation_backward(Tensor grad_output, Tensor input1, Tensor input2,
13 | Tensor grad_input1, Tensor grad_input2, int kH,
14 | int kW, int patchH, int patchW, int padH, int padW,
15 | int dilationH, int dilationW, int dilation_patchH,
16 | int dilation_patchW, int dH, int dW);
17 |
18 | #endif // CORRELATION_PYTORCH_H
19 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/deform_roi_pool_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef DEFORM_ROI_POOL_PYTORCH_H
3 | #define DEFORM_ROI_POOL_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void deform_roi_pool_forward_cuda(Tensor input, Tensor rois, Tensor offset,
8 | Tensor output, int pooled_height,
9 | int pooled_width, float spatial_scale,
10 | int sampling_ratio, float gamma);
11 |
12 | void deform_roi_pool_backward_cuda(Tensor grad_output, Tensor input,
13 | Tensor rois, Tensor offset,
14 | Tensor grad_input, Tensor grad_offset,
15 | int pooled_height, int pooled_width,
16 | float spatial_scale, int sampling_ratio,
17 | float gamma);
18 | #endif // DEFORM_ROI_POOL_PYTORCH_H
19 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/diff_iou_rotated.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | Tensor diff_iou_rotated_sort_vertices_forward_impl(Tensor vertices, Tensor mask,
6 | Tensor num_valid) {
7 | return DISPATCH_DEVICE_IMPL(diff_iou_rotated_sort_vertices_forward_impl,
8 | vertices, mask, num_valid);
9 | }
10 |
11 | Tensor diff_iou_rotated_sort_vertices_forward(Tensor vertices, Tensor mask,
12 | Tensor num_valid) {
13 | return diff_iou_rotated_sort_vertices_forward_impl(vertices, mask, num_valid);
14 | }
15 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/diff_iou_rotated_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "diff_iou_rotated_pytorch.h"
7 |
8 | using namespace parrots;
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | void diff_iou_rotated_sort_vertices_forward_cuda_parrots(
12 | CudaContext& ctx, const SSElement& attr, const OperatorBase::in_list_t& ins,
13 | OperatorBase::out_list_t& outs) {
14 | at::Tensor boxes, scores, dets;
15 | auto vertices = buildATensor(ctx, ins[0]);
16 | auto mask = buildATensor(ctx, ins[1]);
17 | auto num_valid = buildATensor(ctx, ins[2]);
18 | auto out =
19 | diff_iou_rotated_sort_vertices_forward_cuda(vertices, mask, num_valid);
20 | updateDArray(ctx, out, outs[0]);
21 | }
22 |
23 | PARROTS_EXTENSION_REGISTER(diff_iou_rotated_sort_vertices_forward)
24 | .input(3)
25 | .output(1)
26 | .apply(diff_iou_rotated_sort_vertices_forward_cuda_parrots)
27 | .done();
28 | #endif
29 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/diff_iou_rotated_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef DIFF_IOU_ROTATED_PYTORCH_H
3 | #define DIFF_IOU_ROTATED_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | Tensor diff_iou_rotated_sort_vertices_forward_cuda(Tensor vertices, Tensor mask,
8 | Tensor num_valid);
9 |
10 | #endif // DIFF_IOU_ROTATED_PYTORCH_H
11 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/focal_loss_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef FOCAL_LOSS_PYTORCH_H
3 | #define FOCAL_LOSS_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void sigmoid_focal_loss_forward_cuda(Tensor input, Tensor target, Tensor weight,
8 | Tensor output, float gamma, float alpha);
9 |
10 | void sigmoid_focal_loss_backward_cuda(Tensor input, Tensor target,
11 | Tensor weight, Tensor grad_input,
12 | float gamma, float alpha);
13 |
14 | void softmax_focal_loss_forward_cuda(Tensor input, Tensor target, Tensor weight,
15 | Tensor output, float gamma, float alpha);
16 |
17 | void softmax_focal_loss_backward_cuda(Tensor input, Tensor target,
18 | Tensor weight, Tensor buff,
19 | Tensor grad_input, float gamma,
20 | float alpha);
21 | #endif // FOCAL_LOSS_PYTORCH_H
22 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/furthest_point_sample_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef FURTHEST_POINT_SAMPLE_PYTORCH_H
3 | #define FURTHEST_POINT_SAMPLE_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void furthest_point_sampling_forward(Tensor points_tensor, Tensor temp_tensor,
8 | Tensor idx_tensor, int b, int n, int m);
9 |
10 | void furthest_point_sampling_with_dist_forward(Tensor points_tensor,
11 | Tensor temp_tensor,
12 | Tensor idx_tensor, int b, int n,
13 | int m);
14 | #endif // FURTHEST_POINT_SAMPLE_PYTORCH_H
15 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/gather_points.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_cpp_helper.hpp"
2 | #include "pytorch_device_registry.hpp"
3 |
4 | void gather_points_forward_impl(int b, int c, int n, int npoints,
5 | const Tensor points, const Tensor idx,
6 | Tensor out) {
7 | DISPATCH_DEVICE_IMPL(gather_points_forward_impl, b, c, n, npoints, points,
8 | idx, out);
9 | }
10 |
11 | void gather_points_backward_impl(int b, int c, int n, int npoints,
12 | const Tensor grad_out, const Tensor idx,
13 | Tensor grad_points) {
14 | DISPATCH_DEVICE_IMPL(gather_points_backward_impl, b, c, n, npoints, grad_out,
15 | idx, grad_points);
16 | }
17 |
18 | void gather_points_forward(Tensor points_tensor, Tensor idx_tensor,
19 | Tensor out_tensor, int b, int c, int n,
20 | int npoints) {
21 | gather_points_forward_impl(b, c, n, npoints, points_tensor, idx_tensor,
22 | out_tensor);
23 | }
24 |
25 | void gather_points_backward(Tensor grad_out_tensor, Tensor idx_tensor,
26 | Tensor grad_points_tensor, int b, int c, int n,
27 | int npoints) {
28 | gather_points_backward_impl(b, c, n, npoints, grad_out_tensor, idx_tensor,
29 | grad_points_tensor);
30 | }
31 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/gather_points_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef GATHER_POINTS_PYTORCH_H
3 | #define GATHER_POINTS_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void gather_points_forward(Tensor points_tensor, Tensor idx_tensor,
8 | Tensor out_tensor, int b, int c, int n, int npoints);
9 |
10 | void gather_points_backward(Tensor grad_out_tensor, Tensor idx_tensor,
11 | Tensor grad_points_tensor, int b, int c, int n,
12 | int npoints);
13 | #endif // GATHER_POINTS_PYTORCH_H
14 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/group_points_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef GROUP_POINTS_PYTORCH_H
3 | #define GROUP_POINTS_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void group_points_forward(Tensor points_tensor, Tensor idx_tensor,
8 | Tensor out_tensor, int b, int c, int n, int npoints,
9 | int nsample);
10 |
11 | void group_points_backward(Tensor grad_out_tensor, Tensor idx_tensor,
12 | Tensor grad_points_tensor, int b, int c, int n,
13 | int npoints, int nsample);
14 |
15 | #endif // GROUP_POINTS_PYTORCH_H
16 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/iou3d_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef IOU_3D_PYTORCH_H
3 | #define IOU_3D_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void iou3d_boxes_overlap_bev_forward(Tensor boxes_a, Tensor boxes_b,
8 | Tensor ans_overlap);
9 |
10 | void iou3d_nms3d_forward(Tensor boxes, Tensor keep, Tensor keep_num,
11 | float nms_overlap_thresh);
12 |
13 | void iou3d_nms3d_normal_forward(Tensor boxes, Tensor keep, Tensor keep_num,
14 | float nms_overlap_thresh);
15 |
16 | #endif // IOU_3D_PYTORCH_H
17 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/knn.cpp:
--------------------------------------------------------------------------------
1 | // Modified from
2 | // https://github.com/CVMI-Lab/PAConv/tree/main/scene_seg/lib/pointops/src/knnquery_heap
3 |
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void knn_forward_impl(int b, int n, int m, int nsample, const Tensor xyz,
8 | const Tensor new_xyz, Tensor idx, Tensor dist2) {
9 | DISPATCH_DEVICE_IMPL(knn_forward_impl, b, n, m, nsample, xyz, new_xyz, idx,
10 | dist2);
11 | }
12 |
13 | void knn_forward(Tensor xyz_tensor, Tensor new_xyz_tensor, Tensor idx_tensor,
14 | Tensor dist2_tensor, int b, int n, int m, int nsample) {
15 | knn_forward_impl(b, n, m, nsample, xyz_tensor, new_xyz_tensor, idx_tensor,
16 | dist2_tensor);
17 | }
18 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/knn_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "knn_pytorch.h"
7 |
8 | using namespace parrots;
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | void knn_forward_cuda_parrots(CudaContext& ctx, const SSElement& attr,
12 | const OperatorBase::in_list_t& ins,
13 | OperatorBase::out_list_t& outs) {
14 | int b, n, m, nsample;
15 | SSAttrs(attr)
16 | .get("b", b)
17 | .get("n", n)
18 | .get("m", m)
19 | .get("nsample", nsample)
20 | .done();
21 |
22 | auto xyz_tensor = buildATensor(ctx, ins[0]);
23 | auto new_xyz_tensor = buildATensor(ctx, ins[1]);
24 |
25 | auto idx_tensor = buildATensor(ctx, outs[0]);
26 | auto dist2_tensor = buildATensor(ctx, outs[1]);
27 |
28 | knn_forward(xyz_tensor, new_xyz_tensor, idx_tensor, dist2_tensor, b, n, m,
29 | nsample);
30 | }
31 |
32 | PARROTS_EXTENSION_REGISTER(knn_forward)
33 | .attr("b")
34 | .attr("n")
35 | .attr("m")
36 | .attr("nsample")
37 | .input(2)
38 | .output(2)
39 | .apply(knn_forward_cuda_parrots)
40 | .done();
41 | #endif
42 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/knn_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef KNN_PYTORCH_H
3 | #define KNN_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void knn_forward(Tensor xyz_tensor, Tensor new_xyz_tensor, Tensor idx_tensor,
8 | Tensor dist2_tensor, int b, int n, int m, int nsample);
9 | #endif // KNN_PYTORCH_H
10 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/masked_conv2d_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef MASKED_CONV2D_PYTORCH_H
3 | #define MASKED_CONV2D_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void masked_im2col_forward_cuda(const Tensor im, const Tensor mask_h_idx,
8 | const Tensor mask_w_idx, Tensor col,
9 | const int kernel_h, const int kernel_w,
10 | const int pad_h, const int pad_w);
11 |
12 | void masked_col2im_forward_cuda(const Tensor col, const Tensor mask_h_idx,
13 | const Tensor mask_w_idx, Tensor im, int height,
14 | int width, int channels);
15 | #endif // MASKED_CONV2D_PYTORCH_H
16 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/min_area_polygons.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | void min_area_polygons_impl(const Tensor pointsets, Tensor polygons) {
6 | DISPATCH_DEVICE_IMPL(min_area_polygons_impl, pointsets, polygons);
7 | }
8 |
9 | void min_area_polygons(const Tensor pointsets, Tensor polygons) {
10 | min_area_polygons_impl(pointsets, polygons);
11 | }
12 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/min_area_polygons_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "min_area_polygons_pytorch.h"
7 |
8 | using namespace parrots;
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | void min_area_polygons_cuda_parrots(CudaContext& ctx, const SSElement& attr,
12 | const OperatorBase::in_list_t& ins,
13 | OperatorBase::out_list_t& outs) {
14 | auto pointsets = buildATensor(ctx, ins[0]);
15 |
16 | auto polygons = buildATensor(ctx, outs[0]);
17 | min_area_polygons(pointsets, polygons);
18 | }
19 |
20 | PARROTS_EXTENSION_REGISTER(min_area_polygons)
21 | .input(1)
22 | .output(1)
23 | .apply(min_area_polygons_cuda_parrots)
24 | .done();
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/min_area_polygons_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef MIN_AREA_POLYGONS_PYTORCH_H
3 | #define MIN_AREA_POLYGONS_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void min_area_polygons(const Tensor pointsets, Tensor polygons);
8 |
9 | #endif // MIN_AREA_POLYGONS_PYTORCH_H
10 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/modulated_deform_conv_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef MODULATED_DEFORM_CONV_PYTORCH_H
3 | #define MODULATED_DEFORM_CONV_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void modulated_deform_conv_forward(
8 | Tensor input, Tensor weight, Tensor bias, Tensor ones, Tensor offset,
9 | Tensor mask, Tensor output, Tensor columns, int kernel_h, int kernel_w,
10 | const int stride_h, const int stride_w, const int pad_h, const int pad_w,
11 | const int dilation_h, const int dilation_w, const int group,
12 | const int deformable_group, const bool with_bias);
13 |
14 | void modulated_deform_conv_backward(
15 | Tensor input, Tensor weight, Tensor bias, Tensor ones, Tensor offset,
16 | Tensor mask, Tensor columns, Tensor grad_input, Tensor grad_weight,
17 | Tensor grad_bias, Tensor grad_offset, Tensor grad_mask, Tensor grad_output,
18 | int kernel_h, int kernel_w, int stride_h, int stride_w, int pad_h,
19 | int pad_w, int dilation_h, int dilation_w, int group, int deformable_group,
20 | const bool with_bias);
21 | #endif // MODULATED_DEFORM_CONV_PYTORCH_H
22 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/nms.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | Tensor nms_impl(Tensor boxes, Tensor scores, float iou_threshold, int offset) {
6 | return DISPATCH_DEVICE_IMPL(nms_impl, boxes, scores, iou_threshold, offset);
7 | }
8 |
9 | Tensor softnms_impl(Tensor boxes, Tensor scores, Tensor dets,
10 | float iou_threshold, float sigma, float min_score,
11 | int method, int offset) {
12 | return DISPATCH_DEVICE_IMPL(softnms_impl, boxes, scores, dets, iou_threshold,
13 | sigma, min_score, method, offset);
14 | }
15 |
16 | std::vector > nms_match_impl(Tensor dets,
17 | float iou_threshold) {
18 | return DISPATCH_DEVICE_IMPL(nms_match_impl, dets, iou_threshold);
19 | }
20 |
21 | Tensor nms(Tensor boxes, Tensor scores, float iou_threshold, int offset) {
22 | return nms_impl(boxes, scores, iou_threshold, offset);
23 | }
24 |
25 | Tensor softnms(Tensor boxes, Tensor scores, Tensor dets, float iou_threshold,
26 | float sigma, float min_score, int method, int offset) {
27 | return softnms_impl(boxes, scores, dets, iou_threshold, sigma, min_score,
28 | method, offset);
29 | }
30 |
31 | std::vector > nms_match(Tensor dets, float iou_threshold) {
32 | return nms_match_impl(dets, iou_threshold);
33 | }
34 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/nms_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef NMS_PYTORCH_H
3 | #define NMS_PYTORCH_H
4 | #include
5 |
6 | at::Tensor nms(at::Tensor boxes, at::Tensor scores, float iou_threshold,
7 | int offset);
8 |
9 | at::Tensor softnms(at::Tensor boxes, at::Tensor scores, at::Tensor dets,
10 | float iou_threshold, float sigma, float min_score,
11 | int method, int offset);
12 |
13 | std::vector > nms_match(at::Tensor dets, float iou_threshold);
14 |
15 | at::Tensor nms_rotated(const at::Tensor dets, const at::Tensor scores,
16 | const at::Tensor order, const at::Tensor dets_sorted,
17 | const float iou_threshold, const int multi_label);
18 | #endif // NMS_PYTORCH_H
19 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/nms_rotated.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | // modified from
3 | // https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/nms_rotated/nms_rotated.h
4 | #include "pytorch_cpp_helper.hpp"
5 |
6 | Tensor nms_rotated_cpu(const Tensor dets, const Tensor scores,
7 | const float iou_threshold);
8 |
9 | #ifdef MMCV_WITH_CUDA
10 | Tensor nms_rotated_cuda(const Tensor dets, const Tensor scores,
11 | const Tensor order, const Tensor dets_sorted,
12 | const float iou_threshold, const int multi_label);
13 | #endif
14 |
15 | // Interface for Python
16 | // inline is needed to prevent multiple function definitions when this header is
17 | // included by different cpps
18 | Tensor nms_rotated(const Tensor dets, const Tensor scores, const Tensor order,
19 | const Tensor dets_sorted, const float iou_threshold,
20 | const int multi_label) {
21 | assert(dets.device().is_cuda() == scores.device().is_cuda());
22 | if (dets.device().is_cuda()) {
23 | #ifdef MMCV_WITH_CUDA
24 | return nms_rotated_cuda(dets, scores, order, dets_sorted, iou_threshold,
25 | multi_label);
26 | #else
27 | AT_ERROR("Not compiled with GPU support");
28 | #endif
29 | }
30 |
31 | return nms_rotated_cpu(dets, scores, iou_threshold);
32 | }
33 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/pixel_group.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // It is modified from https://github.com/WenmuZhou/PAN.pytorch
3 |
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | std::vector> pixel_group_impl(
8 | Tensor score, Tensor mask, Tensor embedding, Tensor kernel_label,
9 | Tensor kernel_contour, int kernel_region_num, float dis_threshold) {
10 | return DISPATCH_DEVICE_IMPL(pixel_group_impl, score, mask, embedding,
11 | kernel_label, kernel_contour, kernel_region_num,
12 | dis_threshold);
13 | }
14 |
15 | std::vector> pixel_group(
16 | Tensor score, Tensor mask, Tensor embedding, Tensor kernel_label,
17 | Tensor kernel_contour, int kernel_region_num, float distance_threshold) {
18 | score = score.contiguous();
19 | mask = mask.contiguous();
20 | embedding = embedding.contiguous();
21 | kernel_label = kernel_label.contiguous();
22 | kernel_contour = kernel_contour.contiguous();
23 |
24 | return pixel_group_impl(score, mask, embedding, kernel_label, kernel_contour,
25 | kernel_region_num, distance_threshold);
26 | }
27 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/pixel_group_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef PIXEL_GROUP_PYTORCH_H
3 | #define PIXEL_GROUP_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | std::vector> pixel_group(
8 | Tensor score, Tensor mask, Tensor embedding, Tensor kernel_label,
9 | Tensor kernel_contour, int kernel_region_num, float distance_threshold);
10 |
11 | #endif // PIXEL_GROUP_PYTORCH_H
12 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/points_in_boxes_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef POINTS_IN_BOXES_PYTORCH_H
3 | #define POINTS_IN_BOXES_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void points_in_boxes_part_forward(Tensor boxes_tensor, Tensor pts_tensor,
8 | Tensor box_idx_of_points_tensor);
9 |
10 | void points_in_boxes_all_forward(Tensor boxes_tensor, Tensor pts_tensor,
11 | Tensor box_idx_of_points_tensor);
12 |
13 | void points_in_boxes_cpu_forward(Tensor boxes_tensor, Tensor pts_tensor,
14 | Tensor pts_indices_tensor);
15 |
16 | #endif // POINTS_IN_BOXES_PYTORCH_H
17 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/points_in_polygons.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_cpp_helper.hpp"
2 | #include "pytorch_device_registry.hpp"
3 |
4 | void points_in_polygons_forward_impl(const Tensor points, const Tensor polygons,
5 | Tensor output, const int rows,
6 | const int cols) {
7 | DISPATCH_DEVICE_IMPL(points_in_polygons_forward_impl, points, polygons,
8 | output, rows, cols);
9 | }
10 |
11 | void points_in_polygons_forward(Tensor points, Tensor polygons, Tensor output) {
12 | int rows = points.size(0);
13 | int cols = polygons.size(0);
14 | points_in_polygons_forward_impl(points, polygons, output, rows, cols);
15 | }
16 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/points_in_polygons_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "points_in_polygons_pytorch.h"
7 |
8 | using namespace parrots;
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | void points_in_polygons_cuda_parrots(CudaContext& ctx, const SSElement& attr,
12 | const OperatorBase::in_list_t& ins,
13 | OperatorBase::out_list_t& outs) {
14 | auto points = buildATensor(ctx, ins[0]);
15 | auto polygons = buildATensor(ctx, ins[1]);
16 |
17 | auto output = buildATensor(ctx, outs[0]);
18 |
19 | points_in_polygons_forward(points, polygons, output);
20 | }
21 |
22 | PARROTS_EXTENSION_REGISTER(points_in_polygons_forward)
23 | .input(2)
24 | .output(1)
25 | .apply(points_in_polygons_cuda_parrots)
26 | .done();
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/points_in_polygons_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef POINTS_IN_POLYGONS_PYTORCH_H
3 | #define POINTS_IN_POLYGONS_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void points_in_polygons_forward(Tensor points, Tensor polygons, Tensor output);
8 |
9 | #endif // POINTS_IN_POLYGONS_PYTORCH_H
10 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/prroi_pool_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef PRROI_POOL_PYTORCH_H
3 | #define PRROI_POOL_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void prroi_pool_forward(Tensor input, Tensor rois, Tensor output,
8 | int pooled_height, int pooled_width,
9 | float spatial_scale);
10 |
11 | void prroi_pool_backward(Tensor grad_output, Tensor rois, Tensor grad_input,
12 | int pooled_height, int pooled_width,
13 | float spatial_scale);
14 |
15 | void prroi_pool_coor_backward(Tensor output, Tensor grad_output, Tensor input,
16 | Tensor rois, Tensor grad_rois, int pooled_height,
17 | int pooled_width, float spatial_scale);
18 |
19 | #endif // PRROI_POOL_PYTORCH_H
20 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/riroi_align_rotated_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef RIROI_ALIGN_ROTATED_PYTORCH_H
3 | #define RIROI_ALIGN_ROTATED_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void riroi_align_rotated_forward(Tensor features, Tensor rois, Tensor output,
8 | int pooled_height, int pooled_width,
9 | float spatial_scale, int num_samples,
10 | int num_orientations, bool clockwise);
11 |
12 | void riroi_align_rotated_backward(Tensor top_grad, Tensor rois,
13 | Tensor bottom_grad, int pooled_height,
14 | int pooled_width, float spatial_scale,
15 | int num_samples, int num_orientations,
16 | bool clockwise);
17 |
18 | #endif // RIROI_ALIGN_ROTATED_PYTORCH_H
19 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/roi_pool_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef ROI_POOL_PYTORCH_H
3 | #define ROI_POOL_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | #ifdef MMCV_WITH_CUDA
8 | void roi_pool_forward_cuda(Tensor input, Tensor rois, Tensor output,
9 | Tensor argmax, int pooled_height, int pooled_width,
10 | float spatial_scale);
11 |
12 | void roi_pool_backward_cuda(Tensor grad_output, Tensor rois, Tensor argmax,
13 | Tensor grad_input, int pooled_height,
14 | int pooled_width, float spatial_scale);
15 | #endif
16 | #endif // ROI_POOL_PYTORCH_H
17 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/roiaware_pool3d_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef ROIAWARE_POOL3D_PYTORCH_H
3 | #define ROIAWARE_POOL3D_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void roiaware_pool3d_forward(Tensor rois, Tensor pts, Tensor pts_feature,
8 | Tensor argmax, Tensor pts_idx_of_voxels,
9 | Tensor pooled_features, int pool_method);
10 |
11 | void roiaware_pool3d_backward(Tensor pts_idx_of_voxels, Tensor argmax,
12 | Tensor grad_out, Tensor grad_in, int pool_method);
13 |
14 | #endif // ROIAWARE_POOL3D_PYTORCH_H
15 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/roipoint_pool3d_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "roipoint_pool3d_pytorch.h"
7 |
8 | using namespace parrots;
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | void roipoint_pool3d_forward_cuda_parrots(CudaContext& ctx,
12 | const SSElement& attr,
13 | const OperatorBase::in_list_t& ins,
14 | OperatorBase::out_list_t& outs) {
15 | auto xyz = buildATensor(ctx, ins[0]);
16 | auto boxes3d = buildATensor(ctx, ins[1]);
17 | auto pts_feature = buildATensor(ctx, ins[2]);
18 |
19 | auto pooled_features = buildATensor(ctx, outs[0]);
20 | auto pooled_empty_flag = buildATensor(ctx, outs[1]);
21 |
22 | roipoint_pool3d_forward(xyz, boxes3d, pts_feature, pooled_features,
23 | pooled_empty_flag);
24 | }
25 |
26 | PARROTS_EXTENSION_REGISTER(roipoint_pool3d_forward)
27 | .input(3)
28 | .output(2)
29 | .apply(roipoint_pool3d_forward_cuda_parrots)
30 | .done();
31 | #endif
32 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/roipoint_pool3d_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef ROIPOINT_POOL3D_PYTORCH_H
3 | #define ROIPOINT_POOL3D_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void roipoint_pool3d_forward(Tensor xyz, Tensor boxes3d, Tensor pts_feature,
8 | Tensor pooled_features, Tensor pooled_empty_flag);
9 |
10 | #endif // ROIPOINT_POOL3D_PYTORCH_H
11 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/rotated_feature_align_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef ROTATED_FEATURE_ALIGN_PYTORCH_H
3 | #define ROTATED_FEATURE_ALIGN_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void rotated_feature_align_forward(const Tensor features,
8 | const Tensor best_bboxes, Tensor output,
9 | const float spatial_scale, const int points);
10 |
11 | void rotated_feature_align_backward(const Tensor top_grad,
12 | const Tensor best_bboxes,
13 | Tensor bottom_grad,
14 | const float spatial_scale,
15 | const int points);
16 |
17 | #endif // ROTATED_FEATURE_ALIGN_PYTORCH_H
18 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/sync_bn_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef SYNC_BN_PYTORCH_H
3 | #define SYNC_BN_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void sync_bn_forward_mean_cuda(const Tensor input, Tensor mean);
8 |
9 | void sync_bn_forward_var_cuda(const Tensor input, const Tensor mean,
10 | Tensor var);
11 |
12 | void sync_bn_forward_output_cuda(const Tensor input, const Tensor mean,
13 | const Tensor var, Tensor running_mean,
14 | Tensor running_var, const Tensor weight,
15 | const Tensor bias, Tensor norm, Tensor std,
16 | Tensor output, float eps, float momentum,
17 | int group_size);
18 |
19 | void sync_bn_backward_param_cuda(const Tensor grad_output, const Tensor norm,
20 | Tensor grad_weight, Tensor grad_bias);
21 |
22 | void sync_bn_backward_data_cuda(const Tensor grad_output, const Tensor weight,
23 | const Tensor grad_weight,
24 | const Tensor grad_bias, const Tensor norm,
25 | const Tensor std, Tensor grad_input);
26 | #endif // SYNC_BN_PYTORCH_H
27 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/three_interpolate_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef THREE_INTERPOLATE_PYTORCH_H
3 | #define THREE_INTERPOLATE_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void three_interpolate_forward(Tensor points_tensor, Tensor idx_tensor,
8 | Tensor weight_tensor, Tensor out_tensor, int b,
9 | int c, int m, int n);
10 |
11 | void three_interpolate_backward(Tensor grad_out_tensor, Tensor idx_tensor,
12 | Tensor weight_tensor, Tensor grad_points_tensor,
13 | int b, int c, int n, int m);
14 | #endif // THREE_INTERPOLATE_PYTORCH_H
15 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/three_nn.cpp:
--------------------------------------------------------------------------------
1 | // Modified from
2 | // https://github.com/sshaoshuai/Pointnet2.PyTorch/tree/master/pointnet2/src/interpolate.cpp
3 |
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void three_nn_forward_impl(int b, int n, int m, const Tensor unknown,
8 | const Tensor known, Tensor dist2, Tensor idx) {
9 | DISPATCH_DEVICE_IMPL(three_nn_forward_impl, b, n, m, unknown, known, dist2,
10 | idx);
11 | }
12 |
13 | void three_nn_forward(Tensor unknown_tensor, Tensor known_tensor,
14 | Tensor dist2_tensor, Tensor idx_tensor, int b, int n,
15 | int m) {
16 | three_nn_forward_impl(b, n, m, unknown_tensor, known_tensor, dist2_tensor,
17 | idx_tensor);
18 | }
19 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/three_nn_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "three_nn_pytorch.h"
7 |
8 | using namespace parrots;
9 |
10 | #ifdef MMCV_WITH_CUDA
11 | void three_nn_forward_cuda_parrots(CudaContext& ctx, const SSElement& attr,
12 | const OperatorBase::in_list_t& ins,
13 | OperatorBase::out_list_t& outs) {
14 | int b, n, m;
15 | SSAttrs(attr).get("b", b).get("n", n).get("m", m).done();
16 |
17 | auto unknown_tensor = buildATensor(ctx, ins[0]);
18 | auto known_tensor = buildATensor(ctx, ins[1]);
19 |
20 | auto dist2_tensor = buildATensor(ctx, outs[0]);
21 | auto idx_tensor = buildATensor(ctx, outs[1]);
22 |
23 | three_nn_forward(unknown_tensor, known_tensor, dist2_tensor, idx_tensor, b, n,
24 | m);
25 | }
26 |
27 | PARROTS_EXTENSION_REGISTER(three_nn_forward)
28 | .attr("b")
29 | .attr("n")
30 | .attr("m")
31 | .input(2)
32 | .output(2)
33 | .apply(three_nn_forward_cuda_parrots)
34 | .done();
35 | #endif
36 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/three_nn_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef THREE_NN_PYTORCH_H
3 | #define THREE_NN_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void three_nn_forward(Tensor unknown_tensor, Tensor known_tensor,
8 | Tensor dist2_tensor, Tensor idx_tensor, int b, int n,
9 | int m);
10 | #endif // THREE_NN_PYTORCH_H
11 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/tin_shift.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | void tin_shift_forward_impl(Tensor input, Tensor shift, Tensor output) {
6 | DISPATCH_DEVICE_IMPL(tin_shift_forward_impl, input, shift, output);
7 | }
8 |
9 | void tin_shift_backward_impl(Tensor grad_output, Tensor shift,
10 | Tensor grad_input) {
11 | DISPATCH_DEVICE_IMPL(tin_shift_backward_impl, grad_output, shift, grad_input);
12 | }
13 |
14 | void tin_shift_forward(Tensor input, Tensor shift, Tensor output) {
15 | tin_shift_forward_impl(input, shift, output);
16 | }
17 |
18 | void tin_shift_backward(Tensor grad_output, Tensor shift, Tensor grad_input) {
19 | tin_shift_backward_impl(grad_output, shift, grad_input);
20 | }
21 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/tin_shift_parrots.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include
3 | #include
4 | #include
5 |
6 | #include "tin_shift_pytorch.h"
7 | using namespace parrots;
8 |
9 | #ifdef MMCV_WITH_CUDA
10 | void tin_shift_forward_cuda_parrots(CudaContext &ctx, const SSElement &attr,
11 | const OperatorBase::in_list_t &ins,
12 | OperatorBase::out_list_t &outs) {
13 | const auto &input = buildATensor(ctx, ins[0]);
14 | const auto &shift = buildATensor(ctx, ins[1]);
15 | auto output = buildATensor(ctx, outs[0]);
16 | tin_shift_forward_cuda(input, shift, output);
17 | }
18 |
19 | void tin_shift_backward_cuda_parrots(CudaContext &ctx, const SSElement &attr,
20 | const OperatorBase::in_list_t &ins,
21 | OperatorBase::out_list_t &outs) {
22 | const auto &grad_output = buildATensor(ctx, ins[0]);
23 | const auto &shift = buildATensor(ctx, ins[1]);
24 | auto grad_input = buildATensor(ctx, outs[0]);
25 | tin_shift_backward_cuda(grad_output, shift, grad_input);
26 | }
27 |
28 | PARROTS_EXTENSION_REGISTER(tin_shift_forward)
29 | .input(2)
30 | .output(1)
31 | .apply(tin_shift_forward_cuda_parrots)
32 | .done();
33 |
34 | PARROTS_EXTENSION_REGISTER(tin_shift_backward)
35 | .input(2)
36 | .output(1)
37 | .apply(tin_shift_backward_cuda_parrots)
38 | .done();
39 | #endif
40 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/tin_shift_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef TIN_SHIFT_PYTORCH_H
3 | #define TIN_SHIFT_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void tin_shift_forward_cuda(Tensor input, Tensor shift, Tensor output);
8 |
9 | void tin_shift_backward_cuda(Tensor grad_output, Tensor shift,
10 | Tensor grad_input);
11 | #endif // TIN_SHIFT_PYTORCH_H
12 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/parrots/voxelization_pytorch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #ifndef VOXELIZATION_PYTORCH_H
3 | #define VOXELIZATION_PYTORCH_H
4 | #include
5 | using namespace at;
6 |
7 | void hard_voxelize_forward(const at::Tensor &points,
8 | const at::Tensor &voxel_size,
9 | const at::Tensor &coors_range, at::Tensor &voxels,
10 | at::Tensor &coors, at::Tensor &num_points_per_voxel,
11 | at::Tensor &voxel_num, const int max_points,
12 | const int max_voxels, const int NDim = 3,
13 | const bool deterministic = true);
14 |
15 | void dynamic_voxelize_forward(const at::Tensor &points,
16 | const at::Tensor &voxel_size,
17 | const at::Tensor &coors_range, at::Tensor &coors,
18 | const int NDim = 3);
19 |
20 | #endif // VOXELIZATION_PYTORCH_H
21 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/active_rotated_filter.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved.
2 | // Modified from
3 | // https://github.com/csuhan/s2anet/blob/master/mmdet/ops/orn/src/ActiveRotatingFilter.h
4 |
5 | #include "pytorch_cpp_helper.hpp"
6 | #include "pytorch_device_registry.hpp"
7 |
8 | void active_rotated_filter_forward_impl(const Tensor input,
9 | const Tensor indices, Tensor output) {
10 | DISPATCH_DEVICE_IMPL(active_rotated_filter_forward_impl, input, indices,
11 | output);
12 | }
13 |
14 | void active_rotated_filter_backward_impl(const Tensor grad_out,
15 | const Tensor indices, Tensor grad_in) {
16 | DISPATCH_DEVICE_IMPL(active_rotated_filter_backward_impl, grad_out, indices,
17 | grad_in);
18 | }
19 |
20 | void active_rotated_filter_forward(const Tensor input, const Tensor indices,
21 | Tensor output) {
22 | active_rotated_filter_forward_impl(input, indices, output);
23 | }
24 |
25 | void active_rotated_filter_backward(const Tensor grad_out, const Tensor indices,
26 | Tensor grad_in) {
27 | active_rotated_filter_backward_impl(grad_out, indices, grad_in);
28 | }
29 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/bias_act.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_cpp_helper.hpp"
2 | #include "pytorch_device_registry.hpp"
3 |
4 | torch::Tensor bias_act_op_impl(const torch::Tensor &input,
5 | const torch::Tensor &bias,
6 | const torch::Tensor &xref,
7 | const torch::Tensor &yref,
8 | const torch::Tensor &dy, int grad, int dim,
9 | int act, float alpha, float gain, float clamp) {
10 | return DISPATCH_DEVICE_IMPL(bias_act_op_impl, input, bias, xref, yref, dy,
11 | grad, dim, act, alpha, gain, clamp);
12 | }
13 |
14 | torch::Tensor bias_act(const torch::Tensor &input, const torch::Tensor &bias,
15 | const torch::Tensor &xref, const torch::Tensor &yref,
16 | const torch::Tensor &dy, int grad, int dim, int act,
17 | float alpha, float gain, float clamp) {
18 | return bias_act_op_impl(input, bias, xref, yref, dy, grad, dim, act, alpha,
19 | gain, clamp);
20 | }
21 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/border_align.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | void border_align_forward_impl(const Tensor &input, const Tensor &boxes,
6 | Tensor output, Tensor argmax_idx,
7 | const int pool_size) {
8 | DISPATCH_DEVICE_IMPL(border_align_forward_impl, input, boxes, output,
9 | argmax_idx, pool_size);
10 | }
11 |
12 | void border_align_backward_impl(const Tensor &grad_output, const Tensor &boxes,
13 | const Tensor &argmax_idx, Tensor grad_input,
14 | const int pool_size) {
15 | DISPATCH_DEVICE_IMPL(border_align_backward_impl, grad_output, boxes,
16 | argmax_idx, grad_input, pool_size);
17 | }
18 |
19 | void border_align_forward(const Tensor &input, const Tensor &boxes,
20 | Tensor output, Tensor argmax_idx,
21 | const int pool_size) {
22 | border_align_forward_impl(input, boxes, output, argmax_idx, pool_size);
23 | }
24 |
25 | void border_align_backward(const Tensor &grad_output, const Tensor &boxes,
26 | const Tensor &argmax_idx, Tensor grad_input,
27 | const int pool_size) {
28 | border_align_backward_impl(grad_output, boxes, argmax_idx, grad_input,
29 | pool_size);
30 | }
31 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/box_iou_quadri.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | void box_iou_quadri_impl(const Tensor boxes1, const Tensor boxes2, Tensor ious,
6 | const int mode_flag, const bool aligned) {
7 | DISPATCH_DEVICE_IMPL(box_iou_quadri_impl, boxes1, boxes2, ious, mode_flag,
8 | aligned);
9 | }
10 |
11 | // Interface for Python
12 | // inline is needed to prevent multiple function definitions when this header is
13 | // included by different cpps
14 | void box_iou_quadri(const Tensor boxes1, const Tensor boxes2, Tensor ious,
15 | const int mode_flag, const bool aligned) {
16 | box_iou_quadri_impl(boxes1, boxes2, ious, mode_flag, aligned);
17 | }
18 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/box_iou_rotated.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | // modified from
3 | // https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void box_iou_rotated_impl(const Tensor boxes1, const Tensor boxes2, Tensor ious,
8 | const int mode_flag, const bool aligned) {
9 | DISPATCH_DEVICE_IMPL(box_iou_rotated_impl, boxes1, boxes2, ious, mode_flag,
10 | aligned);
11 | }
12 |
13 | // Interface for Python
14 | // inline is needed to prevent multiple function definitions when this header is
15 | // included by different cpps
16 | void box_iou_rotated(const Tensor boxes1, const Tensor boxes2, Tensor ious,
17 | const int mode_flag, const bool aligned) {
18 | box_iou_rotated_impl(boxes1, boxes2, ious, mode_flag, aligned);
19 | }
20 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/convex_iou.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // modified from
3 | // https://github.com/SDL-GuoZonghao/BeyondBoundingBox/tree/main/mmdet/ops/iou/src
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void convex_iou_impl(const Tensor pointsets, const Tensor polygons,
8 | Tensor ious) {
9 | DISPATCH_DEVICE_IMPL(convex_iou_impl, pointsets, polygons, ious);
10 | }
11 |
12 | void convex_iou(const Tensor pointsets, const Tensor polygons, Tensor ious) {
13 | convex_iou_impl(pointsets, polygons, ious);
14 | }
15 |
16 | void convex_giou_impl(const Tensor pointsets, const Tensor polygons,
17 | Tensor output) {
18 | DISPATCH_DEVICE_IMPL(convex_giou_impl, pointsets, polygons, output);
19 | }
20 |
21 | void convex_giou(const Tensor pointsets, const Tensor polygons, Tensor output) {
22 | convex_giou_impl(pointsets, polygons, output);
23 | }
24 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/cuda/ball_query_cuda.cu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // Modified from
3 | // https://github.com/sshaoshuai/Pointnet2.PyTorch/tree/master/pointnet2/src/ball_query_gpu.cu
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | #include "ball_query_cuda_kernel.cuh"
10 | #include "pytorch_cuda_helper.hpp"
11 |
12 | void BallQueryForwardCUDAKernelLauncher(int b, int n, int m, float min_radius,
13 | float max_radius, int nsample,
14 | const Tensor new_xyz, const Tensor xyz,
15 | Tensor idx) {
16 | // new_xyz: (B, M, 3)
17 | // xyz: (B, N, 3)
18 | // output:
19 | // idx: (B, M, nsample)
20 |
21 | at::cuda::CUDAGuard device_guard(new_xyz.device());
22 | cudaStream_t stream = at::cuda::getCurrentCUDAStream();
23 |
24 | // blockIdx.x(col), blockIdx.y(row)
25 | dim3 blocks(GET_BLOCKS(m, THREADS_PER_BLOCK), b);
26 | dim3 threads(THREADS_PER_BLOCK);
27 |
28 | AT_DISPATCH_FLOATING_TYPES_AND_HALF(
29 | new_xyz.scalar_type(), "ball_query_forward_cuda_kernel", [&] {
30 | ball_query_forward_cuda_kernel
31 | <<>>(
32 | b, n, m, min_radius, max_radius, nsample,
33 | new_xyz.data_ptr(), xyz.data_ptr(),
34 | idx.data_ptr());
35 | });
36 |
37 | AT_CUDA_CHECK(cudaGetLastError());
38 | }
39 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/cuda/box_iou_quadri_cuda.cu:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | #include "box_iou_quadri_cuda.cuh"
3 | #include "pytorch_cuda_helper.hpp"
4 |
5 | void box_iou_quadri_cuda(const Tensor boxes1, const Tensor boxes2, Tensor ious,
6 | const int mode_flag, const bool aligned) {
7 | using scalar_t = float;
8 | AT_ASSERTM(boxes1.is_cuda(), "boxes1 must be a CUDA tensor");
9 | AT_ASSERTM(boxes2.is_cuda(), "boxes2 must be a CUDA tensor");
10 |
11 | int output_size = ious.numel();
12 | int num_boxes1 = boxes1.size(0);
13 | int num_boxes2 = boxes2.size(0);
14 |
15 | at::cuda::CUDAGuard device_guard(boxes1.device());
16 | cudaStream_t stream = at::cuda::getCurrentCUDAStream();
17 | box_iou_quadri_cuda_kernel
18 | <<>>(
19 | num_boxes1, num_boxes2, boxes1.data_ptr(),
20 | boxes2.data_ptr(), (scalar_t*)ious.data_ptr(),
21 | mode_flag, aligned);
22 | AT_CUDA_CHECK(cudaGetLastError());
23 | }
24 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/cuda/box_iou_rotated_cuda.cu:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | // modified from
3 | // https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cuda.cu
4 | #include "box_iou_rotated_cuda.cuh"
5 | #include "pytorch_cuda_helper.hpp"
6 |
7 | void box_iou_rotated_cuda(const Tensor boxes1, const Tensor boxes2, Tensor ious,
8 | const int mode_flag, const bool aligned) {
9 | using scalar_t = float;
10 | AT_ASSERTM(boxes1.is_cuda(), "boxes1 must be a CUDA tensor");
11 | AT_ASSERTM(boxes2.is_cuda(), "boxes2 must be a CUDA tensor");
12 |
13 | int output_size = ious.numel();
14 | int num_boxes1 = boxes1.size(0);
15 | int num_boxes2 = boxes2.size(0);
16 |
17 | at::cuda::CUDAGuard device_guard(boxes1.device());
18 | cudaStream_t stream = at::cuda::getCurrentCUDAStream();
19 | box_iou_rotated_cuda_kernel
20 | <<>>(
21 | num_boxes1, num_boxes2, boxes1.data_ptr(),
22 | boxes2.data_ptr(), (scalar_t*)ious.data_ptr(),
23 | mode_flag, aligned);
24 | AT_CUDA_CHECK(cudaGetLastError());
25 | }
26 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/cuda/diff_iou_rotated_cuda.cu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // Adapted from
3 | // https://github.com/lilanxiao/Rotated_IoU/cuda_op/sort_vert_kernel.cu # noqa
4 | #include "diff_iou_rotated_cuda_kernel.cuh"
5 | #include "pytorch_cpp_helper.hpp"
6 | #include "pytorch_cuda_helper.hpp"
7 |
8 | at::Tensor DiffIoURotatedSortVerticesCUDAKernelLauncher(at::Tensor vertices,
9 | at::Tensor mask,
10 | at::Tensor num_valid) {
11 | at::cuda::CUDAGuard device_guard(vertices.device());
12 | cudaStream_t stream = at::cuda::getCurrentCUDAStream();
13 |
14 | CHECK_CONTIGUOUS(vertices);
15 | CHECK_CONTIGUOUS(mask);
16 | CHECK_CONTIGUOUS(num_valid);
17 | CHECK_CUDA(vertices);
18 | CHECK_CUDA(mask);
19 | CHECK_CUDA(num_valid);
20 |
21 | int b = vertices.size(0);
22 | int n = vertices.size(1);
23 | int m = vertices.size(2);
24 | at::Tensor idx =
25 | torch::zeros({b, n, MAX_NUM_VERT_IDX},
26 | at::device(vertices.device()).dtype(at::ScalarType::Int));
27 |
28 | diff_iou_rotated_sort_vertices_forward_cuda_kernel<<>>(
30 | b, n, m, vertices.data_ptr(), mask.data_ptr(),
31 | num_valid.data_ptr(), idx.data_ptr());
32 | AT_CUDA_CHECK(cudaGetLastError());
33 |
34 | return idx;
35 | }
36 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/cuda/knn_cuda.cu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // Modified from
3 | // https://github.com/CVMI-Lab/PAConv/tree/main/scene_seg/lib/pointops/src/knnquery_heap
4 |
5 | #include
6 | #include
7 |
8 | #include "knn_cuda_kernel.cuh"
9 | #include "pytorch_cuda_helper.hpp"
10 |
11 | void KNNForwardCUDAKernelLauncher(int b, int n, int m, int nsample,
12 | const Tensor xyz, const Tensor new_xyz,
13 | Tensor idx, Tensor dist2) {
14 | // param new_xyz: (B, m, 3)
15 | // param xyz: (B, n, 3)
16 | // param idx: (B, m, nsample)
17 |
18 | at::cuda::CUDAGuard device_guard(new_xyz.device());
19 | cudaStream_t stream = at::cuda::getCurrentCUDAStream();
20 |
21 | // blockIdx.x(col), blockIdx.y(row)
22 | dim3 blocks(GET_BLOCKS(m, THREADS_PER_BLOCK), b);
23 | dim3 threads(THREADS_PER_BLOCK);
24 |
25 | AT_DISPATCH_FLOATING_TYPES_AND_HALF(
26 | new_xyz.scalar_type(), "knn_forward_cuda_kernel", [&] {
27 | knn_forward_cuda_kernel<<>>(
28 | b, n, m, nsample, xyz.data_ptr(),
29 | new_xyz.data_ptr(), idx.data_ptr(),
30 | dist2.data_ptr());
31 | });
32 |
33 | AT_CUDA_CHECK(cudaGetLastError());
34 | }
35 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/cuda/min_area_polygons.cu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // modified from
3 | // https://github.com/SDL-GuoZonghao/BeyondBoundingBox/blob/main/mmdet/ops/minareabbox/src/minareabbox_kernel.cu
4 | #include "min_area_polygons_cuda.cuh"
5 | #include "pytorch_cuda_helper.hpp"
6 |
7 | void MinAreaPolygonsCUDAKernelLauncher(const Tensor pointsets,
8 | Tensor polygons) {
9 | int num_pointsets = pointsets.size(0);
10 | const int output_size = polygons.numel();
11 | at::cuda::CUDAGuard device_guard(pointsets.device());
12 | cudaStream_t stream = at::cuda::getCurrentCUDAStream();
13 | AT_DISPATCH_FLOATING_TYPES_AND_HALF(
14 | pointsets.scalar_type(), "min_area_polygons_cuda_kernel", ([&] {
15 | min_area_polygons_cuda_kernel
16 | <<>>(
17 | num_pointsets, pointsets.data_ptr(),
18 | polygons.data_ptr());
19 | }));
20 | AT_CUDA_CHECK(cudaGetLastError());
21 | }
22 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/cuda/points_in_polygons_cuda.cu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // Modified from
3 | // https://github.com/ming71/CUDA/blob/master/point_justify/points_justify_kernel.cu
4 |
5 | #include
6 |
7 | #include "points_in_polygons_cuda_kernel.cuh"
8 | #include "pytorch_cuda_helper.hpp"
9 |
10 | void PointsInPolygonsForwardCUDAKernelLauncher(const at::Tensor points,
11 | const at::Tensor polygons,
12 | const int rows, const int cols,
13 | at::Tensor output) {
14 | const int output_size = rows * cols;
15 | at::cuda::CUDAGuard device_guard(points.device());
16 | cudaStream_t stream = at::cuda::getCurrentCUDAStream();
17 | AT_DISPATCH_FLOATING_TYPES_AND_HALF(
18 | points.scalar_type(), "points_in_polygons_forward_cuda_kernel", ([&] {
19 | const scalar_t *vertex1 = points.data_ptr();
20 | const scalar_t *vertex2 = polygons.data_ptr();
21 | scalar_t *inside_flag = output.data_ptr();
22 |
23 | points_in_polygons_forward_cuda_kernel
24 | <<>>(
25 | output_size, vertex1, vertex2, rows, cols, inside_flag);
26 | }));
27 | AT_CUDA_CHECK(cudaGetLastError());
28 | }
29 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/cuda/three_nn_cuda.cu:
--------------------------------------------------------------------------------
1 | // Modified from
2 | // https://github.com/sshaoshuai/Pointnet2.PyTorch/tree/master/pointnet2/src/interpolate_gpu.cu
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "pytorch_cuda_helper.hpp"
9 | #include "three_nn_cuda_kernel.cuh"
10 |
11 | void ThreeNNForwardCUDAKernelLauncher(int b, int n, int m, const Tensor unknown,
12 | const Tensor known, Tensor dist2,
13 | Tensor idx) {
14 | // unknown: (B, N, 3)
15 | // known: (B, M, 3)
16 | // output:
17 | // dist2: (B, N, 3)
18 | // idx: (B, N, 3)
19 |
20 | at::cuda::CUDAGuard device_guard(unknown.device());
21 | cudaStream_t stream = at::cuda::getCurrentCUDAStream();
22 |
23 | // blockIdx.x(col), blockIdx.y(row)
24 | dim3 blocks(GET_BLOCKS(n, THREADS_PER_BLOCK), b);
25 | dim3 threads(THREADS_PER_BLOCK);
26 |
27 | AT_DISPATCH_FLOATING_TYPES_AND_HALF(
28 | unknown.scalar_type(), "three_nn_forward_cuda_kernel", [&] {
29 | three_nn_forward_cuda_kernel<<>>(
30 | b, n, m, unknown.data_ptr(), known.data_ptr(),
31 | dist2.data_ptr(), idx.data_ptr());
32 | });
33 |
34 | AT_CUDA_CHECK(cudaGetLastError());
35 | }
36 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/diff_iou_rotated.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | Tensor diff_iou_rotated_sort_vertices_forward_impl(Tensor vertices, Tensor mask,
6 | Tensor num_valid) {
7 | return DISPATCH_DEVICE_IMPL(diff_iou_rotated_sort_vertices_forward_impl,
8 | vertices, mask, num_valid);
9 | }
10 |
11 | Tensor diff_iou_rotated_sort_vertices_forward(Tensor vertices, Tensor mask,
12 | Tensor num_valid) {
13 | return diff_iou_rotated_sort_vertices_forward_impl(vertices, mask, num_valid);
14 | }
15 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/gather_points.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_cpp_helper.hpp"
2 | #include "pytorch_device_registry.hpp"
3 |
4 | void gather_points_forward_impl(int b, int c, int n, int npoints,
5 | const Tensor points, const Tensor idx,
6 | Tensor out) {
7 | DISPATCH_DEVICE_IMPL(gather_points_forward_impl, b, c, n, npoints, points,
8 | idx, out);
9 | }
10 |
11 | void gather_points_backward_impl(int b, int c, int n, int npoints,
12 | const Tensor grad_out, const Tensor idx,
13 | Tensor grad_points) {
14 | DISPATCH_DEVICE_IMPL(gather_points_backward_impl, b, c, n, npoints, grad_out,
15 | idx, grad_points);
16 | }
17 |
18 | void gather_points_forward(Tensor points_tensor, Tensor idx_tensor,
19 | Tensor out_tensor, int b, int c, int n,
20 | int npoints) {
21 | gather_points_forward_impl(b, c, n, npoints, points_tensor, idx_tensor,
22 | out_tensor);
23 | }
24 |
25 | void gather_points_backward(Tensor grad_out_tensor, Tensor idx_tensor,
26 | Tensor grad_points_tensor, int b, int c, int n,
27 | int npoints) {
28 | gather_points_backward_impl(b, c, n, npoints, grad_out_tensor, idx_tensor,
29 | grad_points_tensor);
30 | }
31 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/knn.cpp:
--------------------------------------------------------------------------------
1 | // Modified from
2 | // https://github.com/CVMI-Lab/PAConv/tree/main/scene_seg/lib/pointops/src/knnquery_heap
3 |
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void knn_forward_impl(int b, int n, int m, int nsample, const Tensor xyz,
8 | const Tensor new_xyz, Tensor idx, Tensor dist2) {
9 | DISPATCH_DEVICE_IMPL(knn_forward_impl, b, n, m, nsample, xyz, new_xyz, idx,
10 | dist2);
11 | }
12 |
13 | void knn_forward(Tensor xyz_tensor, Tensor new_xyz_tensor, Tensor idx_tensor,
14 | Tensor dist2_tensor, int b, int n, int m, int nsample) {
15 | knn_forward_impl(b, n, m, nsample, xyz_tensor, new_xyz_tensor, idx_tensor,
16 | dist2_tensor);
17 | }
18 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/min_area_polygons.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | void min_area_polygons_impl(const Tensor pointsets, Tensor polygons) {
6 | DISPATCH_DEVICE_IMPL(min_area_polygons_impl, pointsets, polygons);
7 | }
8 |
9 | void min_area_polygons(const Tensor pointsets, Tensor polygons) {
10 | min_area_polygons_impl(pointsets, polygons);
11 | }
12 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/musa/ball_query_musa.mu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // Modified from
3 | // https://github.com/sshaoshuai/Pointnet2.PyTorch/tree/master/pointnet2/src/ball_query_gpu.cu
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | #include "ball_query_musa_kernel.muh"
10 | #include "pytorch_musa_helper.hpp"
11 |
12 | void BallQueryForwardMUSAKernelLauncher(int b, int n, int m, float min_radius,
13 | float max_radius, int nsample,
14 | const Tensor new_xyz, const Tensor xyz,
15 | Tensor idx) {
16 | // new_xyz: (B, M, 3)
17 | // xyz: (B, N, 3)
18 | // output:
19 | // idx: (B, M, nsample)
20 |
21 | c10::musa::MUSAGuard device_guard(new_xyz.device());
22 | musaStream_t stream = c10::musa::getCurrentMUSAStream();
23 |
24 | // blockIdx.x(col), blockIdx.y(row)
25 | dim3 blocks(GET_BLOCKS(m, THREADS_PER_BLOCK), b);
26 | dim3 threads(THREADS_PER_BLOCK);
27 |
28 | AT_DISPATCH_FLOATING_TYPES(
29 | new_xyz.scalar_type(), "ball_query_forward_musa_kernel", [&] {
30 | ball_query_forward_musa_kernel
31 | <<>>(
32 | b, n, m, min_radius, max_radius, nsample,
33 | new_xyz.data_ptr(), xyz.data_ptr(),
34 | idx.data_ptr());
35 | });
36 |
37 | AT_MUSA_CHECK(musaGetLastError());
38 | }
39 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/musa/box_iou_quadri_musa.mu:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | #include "box_iou_quadri_musa.muh"
3 | #include "pytorch_musa_helper.hpp"
4 |
5 | void box_iou_quadri_musa(const Tensor boxes1, const Tensor boxes2, Tensor ious,
6 | const int mode_flag, const bool aligned) {
7 | using scalar_t = float;
8 | AT_ASSERTM(boxes1.is_privateuseone(), "boxes1 must be a MUSA tensor");
9 | AT_ASSERTM(boxes2.is_privateuseone(), "boxes2 must be a MUSA tensor");
10 |
11 | int output_size = ious.numel();
12 | int num_boxes1 = boxes1.size(0);
13 | int num_boxes2 = boxes2.size(0);
14 |
15 | c10::musa::MUSAGuard device_guard(boxes1.device());
16 | musaStream_t stream = c10::musa::getCurrentMUSAStream();
17 | box_iou_quadri_musa_kernel
18 | <<>>(
19 | num_boxes1, num_boxes2, boxes1.data_ptr(),
20 | boxes2.data_ptr(), (scalar_t*)ious.data_ptr(),
21 | mode_flag, aligned);
22 | AT_MUSA_CHECK(musaGetLastError());
23 | }
24 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/musa/box_iou_rotated_musa.mu:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 | // modified from
3 | // https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_musa.cu
4 | #include "box_iou_rotated_musa.muh"
5 | #include "pytorch_musa_helper.hpp"
6 |
7 | void box_iou_rotated_musa(const Tensor boxes1, const Tensor boxes2, Tensor ious,
8 | const int mode_flag, const bool aligned) {
9 | using scalar_t = float;
10 | AT_ASSERTM(boxes1.is_privateuseone(), "boxes1 must be a MUSA tensor");
11 | AT_ASSERTM(boxes2.is_privateuseone(), "boxes2 must be a MUSA tensor");
12 |
13 | int output_size = ious.numel();
14 | int num_boxes1 = boxes1.size(0);
15 | int num_boxes2 = boxes2.size(0);
16 |
17 | c10::musa::MUSAGuard device_guard(boxes1.device());
18 | musaStream_t stream = c10::musa::getCurrentMUSAStream();
19 | box_iou_rotated_musa_kernel
20 | <<>>(
21 | num_boxes1, num_boxes2, boxes1.data_ptr(),
22 | boxes2.data_ptr(), (scalar_t*)ious.data_ptr(),
23 | mode_flag, aligned);
24 | AT_MUSA_CHECK(musaGetLastError());
25 | }
26 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/musa/diff_iou_rotated_musa.mu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // Adapted from
3 | // https://github.com/lilanxiao/Rotated_IoU/musa_op/sort_vert_kernel.cu # noqa
4 | #include "diff_iou_rotated_musa_kernel.muh"
5 | #include "pytorch_cpp_helper.hpp"
6 | #include "pytorch_musa_helper.hpp"
7 |
8 | at::Tensor DiffIoURotatedSortVerticesMUSAKernelLauncher(at::Tensor vertices,
9 | at::Tensor mask,
10 | at::Tensor num_valid) {
11 | c10::musa::MUSAGuard device_guard(vertices.device());
12 | musaStream_t stream = c10::musa::getCurrentMUSAStream();
13 |
14 | CHECK_CONTIGUOUS(vertices);
15 | CHECK_CONTIGUOUS(mask);
16 | CHECK_CONTIGUOUS(num_valid);
17 | CHECK_MUSA(vertices);
18 | CHECK_MUSA(mask);
19 | CHECK_MUSA(num_valid);
20 |
21 | int b = vertices.size(0);
22 | int n = vertices.size(1);
23 | int m = vertices.size(2);
24 | at::Tensor idx =
25 | torch::zeros({b, n, MAX_NUM_VERT_IDX},
26 | at::device(vertices.device()).dtype(at::ScalarType::Int));
27 |
28 | diff_iou_rotated_sort_vertices_forward_musa_kernel<<>>(
30 | b, n, m, vertices.data_ptr(), mask.data_ptr(),
31 | num_valid.data_ptr(), idx.data_ptr());
32 | AT_MUSA_CHECK(musaGetLastError());
33 |
34 | return idx;
35 | }
36 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/musa/knn_musa.mu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // Modified from
3 | // https://github.com/CVMI-Lab/PAConv/tree/main/scene_seg/lib/pointops/src/knnquery_heap
4 |
5 | #include
6 | #include
7 |
8 | #include "knn_musa_kernel.muh"
9 | #include "pytorch_musa_helper.hpp"
10 |
11 | void KNNForwardMUSAKernelLauncher(int b, int n, int m, int nsample,
12 | const Tensor xyz, const Tensor new_xyz,
13 | Tensor idx, Tensor dist2) {
14 | // param new_xyz: (B, m, 3)
15 | // param xyz: (B, n, 3)
16 | // param idx: (B, m, nsample)
17 |
18 | c10::musa::MUSAGuard device_guard(new_xyz.device());
19 | musaStream_t stream = c10::musa::getCurrentMUSAStream();
20 |
21 | // blockIdx.x(col), blockIdx.y(row)
22 | dim3 blocks(GET_BLOCKS(m, THREADS_PER_BLOCK), b);
23 | dim3 threads(THREADS_PER_BLOCK);
24 |
25 | AT_DISPATCH_FLOATING_TYPES(
26 | new_xyz.scalar_type(), "knn_forward_musa_kernel", [&] {
27 | knn_forward_musa_kernel<<>>(
28 | b, n, m, nsample, xyz.data_ptr(),
29 | new_xyz.data_ptr(), idx.data_ptr(),
30 | dist2.data_ptr());
31 | });
32 |
33 | AT_MUSA_CHECK(musaGetLastError());
34 | }
35 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/musa/min_area_polygons.mu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // modified from
3 | // https://github.com/SDL-GuoZonghao/BeyondBoundingBox/blob/main/mmdet/ops/minareabbox/src/minareabbox_kernel.cu
4 | #include "min_area_polygons_musa.muh"
5 | #include "pytorch_musa_helper.hpp"
6 |
7 | void MinAreaPolygonsMUSAKernelLauncher(const Tensor pointsets,
8 | Tensor polygons) {
9 | int num_pointsets = pointsets.size(0);
10 | const int output_size = polygons.numel();
11 | c10::musa::MUSAGuard device_guard(pointsets.device());
12 | musaStream_t stream = c10::musa::getCurrentMUSAStream();
13 | AT_DISPATCH_FLOATING_TYPES(
14 | pointsets.scalar_type(), "min_area_polygons_musa_kernel", ([&] {
15 | min_area_polygons_musa_kernel
16 | <<>>(
17 | num_pointsets, pointsets.data_ptr(),
18 | polygons.data_ptr());
19 | }));
20 | AT_MUSA_CHECK(musaGetLastError());
21 | }
22 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/musa/points_in_polygons_musa.mu:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // Modified from
3 | // https://github.com/ming71/MUSA/blob/master/point_justify/points_justify_kernel.cu
4 |
5 | #include
6 |
7 | #include "points_in_polygons_musa_kernel.muh"
8 | #include "pytorch_musa_helper.hpp"
9 |
10 | void PointsInPolygonsForwardMUSAKernelLauncher(const at::Tensor points,
11 | const at::Tensor polygons,
12 | const int rows, const int cols,
13 | at::Tensor output) {
14 | const int output_size = rows * cols;
15 | c10::musa::MUSAGuard device_guard(points.device());
16 | musaStream_t stream = c10::musa::getCurrentMUSAStream();
17 | AT_DISPATCH_FLOATING_TYPES(
18 | points.scalar_type(), "points_in_polygons_forward_musa_kernel", ([&] {
19 | const scalar_t *vertex1 = points.data_ptr();
20 | const scalar_t *vertex2 = polygons.data_ptr();
21 | scalar_t *inside_flag = output.data_ptr();
22 |
23 | points_in_polygons_forward_musa_kernel
24 | <<>>(
25 | output_size, vertex1, vertex2, rows, cols, inside_flag);
26 | }));
27 | AT_MUSA_CHECK(musaGetLastError());
28 | }
29 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/musa/three_nn_musa.mu:
--------------------------------------------------------------------------------
1 | // Modified from
2 | // https://github.com/sshaoshuai/Pointnet2.PyTorch/tree/master/pointnet2/src/interpolate_gpu.cu
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "pytorch_musa_helper.hpp"
9 | #include "three_nn_musa_kernel.muh"
10 |
11 | void ThreeNNForwardMUSAKernelLauncher(int b, int n, int m, const Tensor unknown,
12 | const Tensor known, Tensor dist2,
13 | Tensor idx) {
14 | // unknown: (B, N, 3)
15 | // known: (B, M, 3)
16 | // output:
17 | // dist2: (B, N, 3)
18 | // idx: (B, N, 3)
19 |
20 | c10::musa::MUSAGuard device_guard(unknown.device());
21 | musaStream_t stream = c10::musa::getCurrentMUSAStream();
22 |
23 | // blockIdx.x(col), blockIdx.y(row)
24 | dim3 blocks(GET_BLOCKS(n, THREADS_PER_BLOCK), b);
25 | dim3 threads(THREADS_PER_BLOCK);
26 |
27 | AT_DISPATCH_FLOATING_TYPES(
28 | unknown.scalar_type(), "three_nn_forward_musa_kernel", [&] {
29 | three_nn_forward_musa_kernel<<>>(
30 | b, n, m, unknown.data_ptr(), known.data_ptr(),
31 | dist2.data_ptr(), idx.data_ptr());
32 | });
33 |
34 | AT_MUSA_CHECK(musaGetLastError());
35 | }
36 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/active_rotated_filter_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void active_rotated_filter_forward_impl(const Tensor input,
7 | const Tensor indices, Tensor output);
8 |
9 | void active_rotated_filter_backward_impl(const Tensor grad_out,
10 | const Tensor indices, Tensor grad_in);
11 |
12 | void active_rotated_filter_forward_npu(const Tensor input, const Tensor indices,
13 | Tensor output) {
14 | OpCommand cmd;
15 | cmd.Name("ActiveRotatedFilter")
16 | .Input(input)
17 | .Input(indices)
18 | .Output(output)
19 | .Run();
20 | }
21 |
22 | void active_rotated_filter_backward_npu(const Tensor grad_out,
23 | const Tensor indices, Tensor grad_in) {
24 | OpCommand cmd;
25 | cmd.Name("ActiveRotatedFilterGrad")
26 | .Input(grad_out)
27 | .Input(indices)
28 | .Output(grad_in)
29 | .Run();
30 | }
31 |
32 | REGISTER_NPU_IMPL(active_rotated_filter_forward_impl,
33 | active_rotated_filter_forward_npu);
34 |
35 | REGISTER_NPU_IMPL(active_rotated_filter_backward_impl,
36 | active_rotated_filter_backward_npu);
37 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/ball_query_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void ball_query_forward_npu(int b, int n, int m, float min_radius,
7 | float max_radius, int nsample, const Tensor new_xyz,
8 | const Tensor xyz, Tensor idx) {
9 | int64_t nsample_i64 = nsample;
10 |
11 | // transpose new_xyz from [B, M, 3] to [M, B, 3]
12 | at::Tensor new_xyz_transpose = new_xyz.transpose(0, 1).to(at::kFloat);
13 |
14 | // transpose xyz from [B, N, 3] to [B, 3, N]
15 | at::Tensor xyz_transpose = xyz.transpose(1, 2).to(at::kFloat);
16 |
17 | // transpose idx from [B, M, nsample] to [M, B, nsample]
18 | at::Tensor idx_transpose = idx.transpose(0, 1).contiguous();
19 |
20 | OpCommand cmd;
21 | cmd.Name("BallQuery")
22 | .Input(xyz_transpose)
23 | .Input(new_xyz_transpose)
24 | .Output(idx_transpose)
25 | .Attr("min_radius", min_radius)
26 | .Attr("max_radius", max_radius)
27 | .Attr("sample_num", nsample_i64)
28 | .Run();
29 |
30 | idx_transpose = idx_transpose.transpose(0, 1).contiguous();
31 | idx.copy_(idx_transpose);
32 | }
33 |
34 | void ball_query_forward_impl(int b, int n, int m, float min_radius,
35 | float max_radius, int nsample,
36 | const Tensor new_xyz, const Tensor xyz,
37 | Tensor idx);
38 |
39 | REGISTER_NPU_IMPL(ball_query_forward_impl, ball_query_forward_npu);
40 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/box_iou_quadri_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void box_iou_quadri_impl(const Tensor boxes1, const Tensor boxes2, Tensor ious,
7 | const int mode_flag, const bool aligned);
8 |
9 | void box_iou_quadri_npu(const Tensor boxes1, const Tensor boxes2, Tensor ious,
10 | const int mode_flag, const bool aligned) {
11 | TORCH_CHECK(boxes1.size(1) == 8, "boxes1 must be 2D tensor (N, 8)");
12 | TORCH_CHECK(boxes1.size(1) == 8, "boxes1 must be 2D tensor (N, 8)");
13 |
14 | EXEC_NPU_CMD(aclnnBoxIou, boxes1, boxes2, mode_flag, aligned, ious);
15 | return;
16 | }
17 |
18 | REGISTER_NPU_IMPL(box_iou_quadri_impl, box_iou_quadri_npu);
19 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/box_iou_rotated_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void box_iou_rotated_impl(const Tensor boxes1, const Tensor boxes2, Tensor ious,
7 | const int mode_flag, const bool aligned);
8 |
9 | void box_iou_rotated_npu(const Tensor boxes1, const Tensor boxes2, Tensor ious,
10 | const int mode_flag, const bool aligned) {
11 | TORCH_CHECK(boxes1.size(1) == 5, "boxes1 must be 2D tensor (N, 5)");
12 | TORCH_CHECK(boxes1.size(1) == 5, "boxes1 must be 2D tensor (N, 5)");
13 | EXEC_NPU_CMD(aclnnBoxIou, boxes1, boxes2, mode_flag, aligned, ious);
14 | return;
15 | }
16 |
17 | REGISTER_NPU_IMPL(box_iou_rotated_impl, box_iou_rotated_npu);
18 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/boxes_overlap_bev_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | namespace {
7 | constexpr int32_t MODE_FLAG_OVERLAP = 0;
8 | constexpr int32_t FORMAT_FLAG_XYZWHDR = 3;
9 | }; // namespace
10 |
11 | void iou3d_boxes_overlap_bev_forward_impl(const int num_a, const Tensor boxes_a,
12 | const int num_b, const Tensor boxes_b,
13 | Tensor ans_overlap);
14 |
15 | void iou3d_boxes_overlap_bev_forward_npu(const int num_a, const Tensor boxes_a,
16 | const int num_b, const Tensor boxes_b,
17 | Tensor ans_overlap) {
18 | TORCH_CHECK(boxes_a.size(1) == 7, "boxes_a must be 2D tensor (N, 7)");
19 | TORCH_CHECK(boxes_b.size(1) == 7, "boxes_b must be 2D tensor (N, 7)");
20 |
21 | auto clockwise = true;
22 | bool aligned = false;
23 | double margin = 1e-5;
24 | int32_t mode_flag = MODE_FLAG_OVERLAP;
25 | int32_t format_flag = FORMAT_FLAG_XYZWHDR;
26 |
27 | EXEC_NPU_CMD(aclnnBoxesOverlapBevV1, boxes_a, boxes_b, format_flag, clockwise,
28 | mode_flag, aligned, margin, ans_overlap);
29 | return;
30 | }
31 |
32 | REGISTER_NPU_IMPL(iou3d_boxes_overlap_bev_forward_impl,
33 | iou3d_boxes_overlap_bev_forward_npu);
34 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/common_util.h:
--------------------------------------------------------------------------------
1 | #ifndef MMCV_OPS_CSRC_COMMON__UTIL_HPP_
2 | #define MMCV_OPS_CSRC_COMMON__UTIL_HPP_
3 |
4 | const int SIZE = 8;
5 |
6 | #endif // MMCV_OPS_CSRC_COMMON__UTIL_HPP_
7 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/diff_iou_rotated_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 | using namespace NPU_NAME_SPACE;
3 | using namespace std;
4 |
5 | Tensor diff_iou_rotated_sort_vertices_npu(Tensor vertices, Tensor mask,
6 | Tensor num_valid) {
7 | TORCH_CHECK(vertices.dim() == 4,
8 | "vertices must be a 4D Tensor, but got: ", vertices.dim());
9 | TORCH_CHECK(mask.dim() == 3,
10 | "mask must be a 3D Tensor, but got: ", mask.dim());
11 | TORCH_CHECK(num_valid.dim() == 2,
12 | "num_valid must be a 2D Tensor, but got: ", num_valid.dim());
13 |
14 | uint32_t B = vertices.size(0);
15 | uint32_t N = vertices.size(1);
16 |
17 | at::Tensor sortedIdx = at::empty({B, N, 9}, num_valid.options());
18 | at::Tensor mask_fp = mask.to(at::kFloat);
19 |
20 | EXEC_NPU_CMD(aclnnDiffIouRotatedSortVertices, vertices, mask_fp, num_valid,
21 | sortedIdx);
22 |
23 | return sortedIdx;
24 | }
25 |
26 | Tensor diff_iou_rotated_sort_vertices_forward_impl(Tensor vertices, Tensor mask,
27 | Tensor num_valid);
28 |
29 | REGISTER_NPU_IMPL(diff_iou_rotated_sort_vertices_forward_impl,
30 | diff_iou_rotated_sort_vertices_npu);
31 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/furthest_point_sample_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void furthest_point_sampling_forward_npu(Tensor points_tensor,
7 | Tensor temp_tensor, Tensor idx_tensor,
8 | int b, int n, int m) {
9 | TORCH_CHECK(
10 | (points_tensor.sizes()[1] >= m),
11 | "the num of sampled points should smaller than total num of points.");
12 | at::Tensor points_xyz = points_tensor.transpose(1, 2).contiguous();
13 | at::Tensor nearest_dist = temp_tensor.contiguous();
14 | EXEC_NPU_CMD(aclnnFurthestPointSampling, points_xyz, nearest_dist, m,
15 | idx_tensor);
16 | }
17 |
18 | void furthest_point_sampling_forward_impl(Tensor points_tensor,
19 | Tensor temp_tensor, Tensor idx_tensor,
20 | int b, int n, int m);
21 |
22 | REGISTER_NPU_IMPL(furthest_point_sampling_forward_impl,
23 | furthest_point_sampling_forward_npu);
24 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/furthest_point_sampling_with_dist_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 | using namespace NPU_NAME_SPACE;
3 | using namespace std;
4 |
5 | void furthest_point_sampling_with_dist_npu(Tensor points_tensor,
6 | Tensor temp_tensor,
7 | Tensor idx_tensor, int b, int n,
8 | int m) {
9 | TORCH_CHECK(
10 | (points_tensor.sizes()[1] >= m),
11 | "the num of sampled points should smaller than total num of points.");
12 | EXEC_NPU_CMD(aclnnFurthestPointSamplingWithDist, points_tensor, temp_tensor,
13 | m, idx_tensor);
14 | }
15 |
16 | void furthest_point_sampling_with_dist_forward_impl(Tensor points_tensor,
17 | Tensor temp_tensor,
18 | Tensor idx_tensor, int b,
19 | int n, int m);
20 |
21 | REGISTER_NPU_IMPL(furthest_point_sampling_with_dist_forward_impl,
22 | furthest_point_sampling_with_dist_npu);
23 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/knn_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 | #include "torch_npu/csrc/aten/NPUNativeFunctions.h"
3 | #include "torch_npu/csrc/framework/utils/OpAdapter.h"
4 |
5 | using namespace NPU_NAME_SPACE;
6 | using namespace std;
7 |
8 | void knn_forward_npu(int b, int n, int m, int nsample, const Tensor xyz,
9 | const Tensor new_xyz, Tensor idx, Tensor dist2) {
10 | // transpose known from [B, N, 3] to [B, 3, N]
11 | at::Tensor source = xyz.transpose(2, 1).contiguous();
12 | at::Tensor target = new_xyz.contiguous();
13 |
14 | bool is_from_knn = true;
15 | EXEC_NPU_CMD(aclnnKnn, source, target, is_from_knn, nsample, dist2, idx);
16 | }
17 |
18 | void knn_forward_impl(int b, int n, int m, int nsample, const Tensor xyz,
19 | const Tensor new_xyz, Tensor idx, Tensor dist2);
20 |
21 | REGISTER_NPU_IMPL(knn_forward_impl, knn_forward_npu);
22 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/nms3d_normal_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 |
5 | void iou3d_nms3d_normal_forward_npu(const Tensor boxes, Tensor &keep,
6 | Tensor &num_out, float nms_overlap_thresh) {
7 | int32_t box_num = boxes.size(0);
8 | int32_t data_align = 16;
9 | int32_t mask_num = ((box_num - 1) / data_align + 1) * data_align;
10 | const double iou_threshold = nms_overlap_thresh;
11 | at::Tensor mask =
12 | at::empty({box_num, mask_num}, boxes.options().dtype(at::kShort));
13 | EXEC_NPU_CMD(aclnnNms3dNormal, boxes, iou_threshold, mask);
14 |
15 | Tensor keep_t = at::zeros({box_num}, mask.options());
16 | Tensor num_out_t = at::zeros(1, mask.options());
17 | EXEC_NPU_CMD(aclnnGatherNms3dMask, mask, keep_t, num_out_t);
18 | num_out.fill_(num_out_t.item().toLong());
19 | keep.copy_(keep_t);
20 | }
21 |
22 | void iou3d_nms3d_normal_forward_impl(const Tensor boxes, Tensor &keep,
23 | Tensor &num_out, float nms_overlap_thresh);
24 |
25 | REGISTER_NPU_IMPL(iou3d_nms3d_normal_forward_impl,
26 | iou3d_nms3d_normal_forward_npu);
27 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/nms3d_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | constexpr int32_t BOX_DIM = 7;
7 |
8 | void iou3d_nms3d_forward_npu(const Tensor boxes, Tensor &keep, Tensor &num_out,
9 | float nms_overlap_thresh) {
10 | TORCH_CHECK((boxes.sizes()[1] == BOX_DIM),
11 | "Input boxes shape should be (N, 7)");
12 | int32_t box_num = boxes.size(0);
13 | int32_t data_align = 16;
14 | int32_t mask_num = ((box_num - 1) / data_align + 1) * data_align;
15 | const double iou_threshold = nms_overlap_thresh;
16 | at::Tensor mask =
17 | at::empty({box_num, mask_num}, boxes.options().dtype(at::kShort));
18 | EXEC_NPU_CMD(aclnnNms3d, boxes, iou_threshold, mask);
19 |
20 | Tensor keep_t = at::zeros({box_num}, mask.options());
21 | Tensor num_out_t = at::zeros(1, mask.options());
22 | EXEC_NPU_CMD(aclnnGatherNms3dMask, mask, keep_t, num_out_t);
23 | num_out.fill_(num_out_t.item().toLong());
24 | keep.copy_(keep_t);
25 | }
26 |
27 | void iou3d_nms3d_forward_impl(const Tensor boxes, Tensor &keep, Tensor &num_out,
28 | float nms_overlap_thresh);
29 |
30 | REGISTER_NPU_IMPL(iou3d_nms3d_forward_impl, iou3d_nms3d_forward_npu);
31 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/nms_rotated_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "common_util.h"
2 | #include "pytorch_npu_helper.hpp"
3 |
4 | using namespace NPU_NAME_SPACE;
5 |
6 | Tensor nms_rotated_npu(const Tensor dets, const Tensor scores,
7 | const Tensor labels, const float iou_threshold) {
8 | auto originDtype = dets.scalar_type();
9 | at::Tensor detsCast = dets;
10 | at::Tensor scoresCast = scores;
11 | if (originDtype != at::kFloat) {
12 | detsCast = detsCast.to(at::kFloat);
13 | scoresCast = scoresCast.to(at::kFloat);
14 | }
15 | c10::SmallVector selectedIndexSize = {dets.size(0)};
16 |
17 | at::Tensor selectedBox = at::empty_like(dets);
18 | at::Tensor selectedIndex =
19 | at::empty(selectedIndexSize, dets.options().dtype(at::kInt));
20 |
21 | c10::SmallVector output_sync_idx = {0, 1};
22 | OpCommand cmd;
23 | cmd.Sync(output_sync_idx)
24 | .Name("RotatedNMS")
25 | .Input(detsCast)
26 | .Input(scoresCast)
27 | .Input(labels)
28 | .Output(selectedBox)
29 | .Output(selectedIndex)
30 | .Attr("iou_threshold", (float)iou_threshold)
31 | .Attr("is_angle", false)
32 | .Run();
33 | selectedIndex = selectedIndex.to(at::kLong);
34 | return selectedIndex;
35 | }
36 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/points_in_box_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void points_in_boxes_part_forward_impl_npu(int batch_size, int boxes_num,
7 | int pts_num, const Tensor boxes,
8 | const Tensor pts,
9 | Tensor box_idx_of_points) {
10 | c10::SmallVector output_size = {pts.size(0), pts.size(1)};
11 | auto boxes_trans = boxes.transpose(1, 2).contiguous();
12 | EXEC_NPU_CMD(aclnnPointsInBox, boxes_trans, pts, box_idx_of_points);
13 | }
14 | void points_in_boxes_part_forward_impl(int batch_size, int boxes_num,
15 | int pts_num, const Tensor boxes,
16 | const Tensor pts,
17 | Tensor box_idx_of_points);
18 | REGISTER_NPU_IMPL(points_in_boxes_part_forward_impl,
19 | points_in_boxes_part_forward_impl_npu);
20 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/points_in_box_npu_all.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void points_in_boxes_all_forward_impl_npu(int batch_size, int boxes_num,
7 | int pts_num, const Tensor boxes,
8 | const Tensor pts,
9 | Tensor box_idx_of_points) {
10 | c10::SmallVector output_size = {pts.size(0), pts.size(1),
11 | boxes.size(1)};
12 | auto boxes_trans = boxes.transpose(1, 2).contiguous();
13 | EXEC_NPU_CMD(aclnnPointsInBoxAll, boxes_trans, pts, box_idx_of_points);
14 | }
15 | void points_in_boxes_all_forward_impl(int batch_size, int boxes_num,
16 | int pts_num, const Tensor boxes,
17 | const Tensor pts,
18 | Tensor box_idx_of_points);
19 | REGISTER_NPU_IMPL(points_in_boxes_all_forward_impl,
20 | points_in_boxes_all_forward_impl_npu);
21 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/points_in_polygons_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | constexpr int32_t MAX_POLYGONS_BATCH = 2800;
7 |
8 | void points_in_polygons_npu(const Tensor points, Tensor polygons, Tensor output,
9 | const int rows, const int cols) {
10 | TORCH_CHECK(
11 | (polygons.sizes()[0] <= MAX_POLYGONS_BATCH),
12 | "The batch of polygons tensor must be less than MAX_POLYGONS_BATCH");
13 | at::Tensor trans_polygons = polygons.transpose(0, 1);
14 | OpCommand cmd;
15 | at::Tensor new_trans_polygons = trans_polygons.contiguous();
16 | cmd.Name("PointsInPolygons")
17 | .Input(points, (string) "points")
18 | .Input(new_trans_polygons, (string) "polygons")
19 | .Output(output)
20 | .Run();
21 | }
22 |
23 | void points_in_polygons_forward_impl(const Tensor points, Tensor polygons,
24 | Tensor output, const int rows,
25 | const int cols);
26 |
27 | REGISTER_NPU_IMPL(points_in_polygons_forward_impl, points_in_polygons_npu);
28 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/stack_ball_query_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void stack_ball_query_forward_npu(float max_radius, int nsample,
7 | const Tensor new_xyz,
8 | const Tensor new_xyz_batch_cnt,
9 | const Tensor xyz, const Tensor xyz_batch_cnt,
10 | Tensor idx) {
11 | at::Tensor xyz_transpose = xyz.transpose(0, 1).contiguous();
12 | double max_radius_double = double(max_radius);
13 | EXEC_NPU_CMD(aclnnStackBallQuery, xyz_transpose, new_xyz, xyz_batch_cnt,
14 | new_xyz_batch_cnt, max_radius_double, nsample, idx);
15 | }
16 |
17 | void stack_ball_query_forward_impl(float max_radius, int nsample,
18 | const Tensor new_xyz,
19 | const Tensor new_xyz_batch_cnt,
20 | const Tensor xyz, const Tensor xyz_batch_cnt,
21 | Tensor idx);
22 |
23 | REGISTER_NPU_IMPL(stack_ball_query_forward_impl, stack_ball_query_forward_npu);
24 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/stack_group_points_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 |
3 | using namespace NPU_NAME_SPACE;
4 | using namespace std;
5 |
6 | void stack_group_points_forward_npu(int b, int c, int n, int nsample,
7 | const Tensor features_tensor,
8 | const Tensor features_batch_cnt_tensor,
9 | const Tensor idx_tensor,
10 | const Tensor idx_batch_cnt_tensor,
11 | Tensor out_tensor) {
12 | EXEC_NPU_CMD(aclnnStackGroupPoints, features_tensor,
13 | features_batch_cnt_tensor, idx_tensor, idx_batch_cnt_tensor,
14 | out_tensor);
15 | }
16 |
17 | void stack_group_points_forward_impl(int b, int c, int n, int nsample,
18 | const Tensor features_tensor,
19 | const Tensor features_batch_cnt_tensor,
20 | const Tensor idx_tensor,
21 | const Tensor idx_batch_cnt_tensor,
22 | Tensor out_tensor);
23 |
24 | REGISTER_NPU_IMPL(stack_group_points_forward_impl,
25 | stack_group_points_forward_npu);
26 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/npu/three_nn_npu.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_npu_helper.hpp"
2 | #include "torch_npu/csrc/aten/NPUNativeFunctions.h"
3 | #include "torch_npu/csrc/framework/utils/OpAdapter.h"
4 |
5 | using namespace NPU_NAME_SPACE;
6 | using namespace std;
7 |
8 | void three_nn_forward_npu(int b, int n, int m, const Tensor unknown,
9 | const Tensor known, Tensor dist2, Tensor idx) {
10 | at::Tensor source = known.contiguous();
11 | at::Tensor target = unknown.contiguous();
12 |
13 | bool is_from_knn = false;
14 | int nsample = 3;
15 | EXEC_NPU_CMD(aclnnKnn, source, target, is_from_knn, nsample, dist2, idx);
16 | }
17 |
18 | void three_nn_forward_impl(int b, int n, int m, const Tensor unknown,
19 | const Tensor known, Tensor dist2, Tensor idx);
20 |
21 | REGISTER_NPU_IMPL(three_nn_forward_impl, three_nn_forward_npu);
22 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/pixel_group.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | // It is modified from https://github.com/WenmuZhou/PAN.pytorch
3 |
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | std::vector> pixel_group_impl(
8 | Tensor score, Tensor mask, Tensor embedding, Tensor kernel_label,
9 | Tensor kernel_contour, int kernel_region_num, float dis_threshold) {
10 | return DISPATCH_DEVICE_IMPL(pixel_group_impl, score, mask, embedding,
11 | kernel_label, kernel_contour, kernel_region_num,
12 | dis_threshold);
13 | }
14 |
15 | std::vector> pixel_group(
16 | Tensor score, Tensor mask, Tensor embedding, Tensor kernel_label,
17 | Tensor kernel_contour, int kernel_region_num, float distance_threshold) {
18 | score = score.contiguous();
19 | mask = mask.contiguous();
20 | embedding = embedding.contiguous();
21 | kernel_label = kernel_label.contiguous();
22 | kernel_contour = kernel_contour.contiguous();
23 |
24 | return pixel_group_impl(score, mask, embedding, kernel_label, kernel_contour,
25 | kernel_region_num, distance_threshold);
26 | }
27 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/points_in_polygons.cpp:
--------------------------------------------------------------------------------
1 | #include "pytorch_cpp_helper.hpp"
2 | #include "pytorch_device_registry.hpp"
3 |
4 | void points_in_polygons_forward_impl(const Tensor points, const Tensor polygons,
5 | Tensor output, const int rows,
6 | const int cols) {
7 | DISPATCH_DEVICE_IMPL(points_in_polygons_forward_impl, points, polygons,
8 | output, rows, cols);
9 | }
10 |
11 | void points_in_polygons_forward(Tensor points, Tensor polygons, Tensor output) {
12 | int rows = points.size(0);
13 | int cols = polygons.size(0);
14 | points_in_polygons_forward_impl(points, polygons, output, rows, cols);
15 | }
16 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/three_nn.cpp:
--------------------------------------------------------------------------------
1 | // Modified from
2 | // https://github.com/sshaoshuai/Pointnet2.PyTorch/tree/master/pointnet2/src/interpolate.cpp
3 |
4 | #include "pytorch_cpp_helper.hpp"
5 | #include "pytorch_device_registry.hpp"
6 |
7 | void three_nn_forward_impl(int b, int n, int m, const Tensor unknown,
8 | const Tensor known, Tensor dist2, Tensor idx) {
9 | DISPATCH_DEVICE_IMPL(three_nn_forward_impl, b, n, m, unknown, known, dist2,
10 | idx);
11 | }
12 |
13 | void three_nn_forward(Tensor unknown_tensor, Tensor known_tensor,
14 | Tensor dist2_tensor, Tensor idx_tensor, int b, int n,
15 | int m) {
16 | three_nn_forward_impl(b, n, m, unknown_tensor, known_tensor, dist2_tensor,
17 | idx_tensor);
18 | }
19 |
--------------------------------------------------------------------------------
/mmcv/ops/csrc/pytorch/tin_shift.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) OpenMMLab. All rights reserved
2 | #include "pytorch_cpp_helper.hpp"
3 | #include "pytorch_device_registry.hpp"
4 |
5 | void tin_shift_forward_impl(Tensor input, Tensor shift, Tensor output) {
6 | DISPATCH_DEVICE_IMPL(tin_shift_forward_impl, input, shift, output);
7 | }
8 |
9 | void tin_shift_backward_impl(Tensor grad_output, Tensor shift,
10 | Tensor grad_input) {
11 | DISPATCH_DEVICE_IMPL(tin_shift_backward_impl, grad_output, shift, grad_input);
12 | }
13 |
14 | void tin_shift_forward(Tensor input, Tensor shift, Tensor output) {
15 | tin_shift_forward_impl(input, shift, output);
16 | }
17 |
18 | void tin_shift_backward(Tensor grad_output, Tensor shift, Tensor grad_input) {
19 | tin_shift_backward_impl(grad_output, shift, grad_input);
20 | }
21 |
--------------------------------------------------------------------------------
/mmcv/ops/info.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 |
4 | if torch.__version__ == 'parrots':
5 | import parrots
6 |
7 | def get_compiler_version():
8 | return 'GCC ' + parrots.version.compiler
9 |
10 | def get_compiling_cuda_version():
11 | return parrots.version.cuda
12 | else:
13 | from ..utils import ext_loader
14 | ext_module = ext_loader.load_ext(
15 | '_ext', ['get_compiler_version', 'get_compiling_cuda_version'])
16 |
17 | def get_compiler_version():
18 | return ext_module.get_compiler_version()
19 |
20 | def get_compiling_cuda_version():
21 | return ext_module.get_compiling_cuda_version()
22 |
--------------------------------------------------------------------------------
/mmcv/ops/min_area_polygons.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 |
4 | from ..utils import ext_loader
5 |
6 | ext_module = ext_loader.load_ext('_ext', ['min_area_polygons'])
7 |
8 |
9 | def min_area_polygons(pointsets: torch.Tensor) -> torch.Tensor:
10 | """Find the smallest polygons that surrounds all points in the point sets.
11 |
12 | Args:
13 | pointsets (Tensor): point sets with shape (N, 18).
14 |
15 | Returns:
16 | torch.Tensor: Return the smallest polygons with shape (N, 8).
17 | """
18 | polygons = pointsets.new_zeros((pointsets.size(0), 8))
19 | ext_module.min_area_polygons(pointsets, polygons)
20 | return polygons
21 |
--------------------------------------------------------------------------------
/mmcv/transforms/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from .base import BaseTransform
3 | from .builder import TRANSFORMS
4 | from .loading import LoadAnnotations, LoadImageFromFile
5 | from .processing import (CenterCrop, MultiScaleFlipAug, Normalize, Pad,
6 | RandomChoiceResize, RandomFlip, RandomGrayscale,
7 | RandomResize, Resize, TestTimeAug)
8 | from .wrappers import (Compose, KeyMapper, RandomApply, RandomChoice,
9 | TransformBroadcaster)
10 |
11 | try:
12 | import torch # noqa: F401
13 | except ImportError:
14 | __all__ = [
15 | 'BaseTransform', 'TRANSFORMS', 'TransformBroadcaster', 'Compose',
16 | 'RandomChoice', 'KeyMapper', 'LoadImageFromFile', 'LoadAnnotations',
17 | 'Normalize', 'Resize', 'Pad', 'RandomFlip', 'RandomChoiceResize',
18 | 'CenterCrop', 'RandomGrayscale', 'MultiScaleFlipAug', 'RandomResize',
19 | 'RandomApply', 'TestTimeAug'
20 | ]
21 | else:
22 | from .formatting import ImageToTensor, ToTensor, to_tensor
23 |
24 | __all__ = [
25 | 'BaseTransform', 'TRANSFORMS', 'TransformBroadcaster', 'Compose',
26 | 'RandomChoice', 'KeyMapper', 'LoadImageFromFile', 'LoadAnnotations',
27 | 'Normalize', 'Resize', 'Pad', 'ToTensor', 'to_tensor', 'ImageToTensor',
28 | 'RandomFlip', 'RandomChoiceResize', 'CenterCrop', 'RandomGrayscale',
29 | 'MultiScaleFlipAug', 'RandomResize', 'RandomApply', 'TestTimeAug'
30 | ]
31 |
--------------------------------------------------------------------------------
/mmcv/transforms/base.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from abc import ABCMeta, abstractmethod
3 | from typing import Dict, List, Optional, Tuple, Union
4 |
5 |
6 | class BaseTransform(metaclass=ABCMeta):
7 | """Base class for all transformations."""
8 |
9 | def __call__(self,
10 | results: Dict) -> Optional[Union[Dict, Tuple[List, List]]]:
11 |
12 | return self.transform(results)
13 |
14 | @abstractmethod
15 | def transform(self,
16 | results: Dict) -> Optional[Union[Dict, Tuple[List, List]]]:
17 | """The transform function. All subclass of BaseTransform should
18 | override this method.
19 |
20 | This function takes the result dict as the input, and can add new
21 | items to the dict or modify existing items in the dict. And the result
22 | dict will be returned in the end, which allows to concate multiple
23 | transforms into a pipeline.
24 |
25 | Args:
26 | results (dict): The result dict.
27 |
28 | Returns:
29 | dict: The result dict.
30 | """
31 |
--------------------------------------------------------------------------------
/mmcv/transforms/builder.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from mmengine.registry import TRANSFORMS # noqa: F401
3 |
--------------------------------------------------------------------------------
/mmcv/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from .device_type import (IS_CUDA_AVAILABLE, IS_MLU_AVAILABLE,
3 | IS_MPS_AVAILABLE, IS_MUSA_AVAILABLE,
4 | IS_NPU_AVAILABLE)
5 | from .env import collect_env
6 | from .parrots_jit import jit, skip_no_elena
7 |
8 | __all__ = [
9 | 'IS_MLU_AVAILABLE', 'IS_MPS_AVAILABLE', 'IS_CUDA_AVAILABLE',
10 | 'IS_NPU_AVAILABLE', 'IS_MUSA_AVAILABLE', 'collect_env', 'jit',
11 | 'skip_no_elena'
12 | ]
13 |
--------------------------------------------------------------------------------
/mmcv/utils/device_type.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from mmengine.device import (is_cuda_available, is_mlu_available,
3 | is_mps_available, is_musa_available,
4 | is_npu_available)
5 |
6 | IS_MLU_AVAILABLE = is_mlu_available()
7 | IS_MPS_AVAILABLE = is_mps_available()
8 | IS_CUDA_AVAILABLE = is_cuda_available()
9 | IS_NPU_AVAILABLE = is_npu_available()
10 | IS_MUSA_AVAILABLE = is_musa_available()
11 |
--------------------------------------------------------------------------------
/mmcv/utils/parrots_jit.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import os
3 |
4 | from mmengine.utils.dl_utils.parrots_wrapper import TORCH_VERSION
5 |
6 | parrots_jit_option = os.getenv('PARROTS_JIT_OPTION')
7 |
8 | if TORCH_VERSION == 'parrots' and parrots_jit_option == 'ON':
9 | from parrots.jit import pat as jit
10 | else:
11 |
12 | def jit(func=None,
13 | check_input=None,
14 | full_shape=True,
15 | derivate=False,
16 | coderize=False,
17 | optimize=False):
18 |
19 | def wrapper(func):
20 |
21 | def wrapper_inner(*args, **kargs):
22 | return func(*args, **kargs)
23 |
24 | return wrapper_inner
25 |
26 | if func is None:
27 | return wrapper
28 | else:
29 | return func
30 |
31 |
32 | if TORCH_VERSION == 'parrots':
33 | from parrots.utils.tester import skip_no_elena
34 | else:
35 |
36 | def skip_no_elena(func):
37 |
38 | def wrapper(*args, **kargs):
39 | return func(*args, **kargs)
40 |
41 | return wrapper
42 |
--------------------------------------------------------------------------------
/mmcv/version.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | __version__ = '2.2.0'
3 |
4 |
5 | def parse_version_info(version_str: str, length: int = 4) -> tuple:
6 | """Parse a version string into a tuple.
7 |
8 | Args:
9 | version_str (str): The version string.
10 | length (int): The maximum number of version levels. Default: 4.
11 |
12 | Returns:
13 | tuple[int | str]: The version info, e.g., "1.3.0" is parsed into
14 | (1, 3, 0, 0, 0, 0), and "2.0.0rc1" is parsed into
15 | (2, 0, 0, 0, 'rc', 1) (when length is set to 4).
16 | """
17 | from packaging.version import parse
18 | version = parse(version_str)
19 | assert version.release, f'failed to parse version {version_str}'
20 | release = list(version.release)
21 | release = release[:length]
22 | if len(release) < length:
23 | release = release + [0] * (length - len(release))
24 | if version.is_prerelease:
25 | release.extend(list(version.pre)) # type: ignore
26 | elif version.is_postrelease:
27 | release.extend(list(version.post)) # type: ignore
28 | else:
29 | release.extend([0, 0])
30 | return tuple(release)
31 |
32 |
33 | version_info = tuple(int(x) for x in __version__.split('.')[:3])
34 |
35 | __all__ = ['__version__', 'version_info', 'parse_version_info']
36 |
--------------------------------------------------------------------------------
/mmcv/video/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from .io import Cache, VideoReader, frames2video
3 | from .optflow import (dequantize_flow, flow_from_bytes, flow_warp, flowread,
4 | flowwrite, quantize_flow, sparse_flow_from_bytes)
5 | from .processing import concat_video, convert_video, cut_video, resize_video
6 |
7 | __all__ = [
8 | 'Cache', 'VideoReader', 'frames2video', 'convert_video', 'resize_video',
9 | 'cut_video', 'concat_video', 'flowread', 'flowwrite', 'quantize_flow',
10 | 'dequantize_flow', 'flow_warp', 'flow_from_bytes', 'sparse_flow_from_bytes'
11 | ]
12 |
--------------------------------------------------------------------------------
/mmcv/visualization/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from .color import Color, color_val
3 | from .image import imshow, imshow_bboxes, imshow_det_bboxes
4 | from .optflow import flow2rgb, flowshow, make_color_wheel
5 |
6 | __all__ = [
7 | 'Color', 'color_val', 'imshow', 'imshow_bboxes', 'imshow_det_bboxes',
8 | 'flowshow', 'flow2rgb', 'make_color_wheel'
9 | ]
10 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | -r requirements/build.txt
2 | -r requirements/optional.txt
3 | -r requirements/runtime.txt
4 | -r requirements/test.txt
5 |
--------------------------------------------------------------------------------
/requirements/build.txt:
--------------------------------------------------------------------------------
1 | pytest-runner
2 |
--------------------------------------------------------------------------------
/requirements/docs.txt:
--------------------------------------------------------------------------------
1 | docutils==0.16.0
2 | markdown>=3.4.0
3 | myst-parser
4 | opencv-python
5 | -e git+https://github.com/open-mmlab/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
6 | sphinx==4.0.2
7 | sphinx-copybutton
8 | sphinx_markdown_tables>=0.0.16
9 | torch
10 | urllib3<2.0.0
11 |
--------------------------------------------------------------------------------
/requirements/optional.txt:
--------------------------------------------------------------------------------
1 | ninja
2 | psutil
3 |
--------------------------------------------------------------------------------
/requirements/runtime.txt:
--------------------------------------------------------------------------------
1 | addict
2 | mmengine>=0.3.0
3 | numpy
4 | packaging
5 | Pillow
6 | pyyaml
7 | regex;sys_platform=='win32'
8 | yapf
9 |
--------------------------------------------------------------------------------
/requirements/test.txt:
--------------------------------------------------------------------------------
1 | coverage
2 | lmdb
3 | onnx
4 | onnxoptimizer
5 | onnxruntime
6 | pytest
7 | PyTurboJPEG
8 | scipy
9 | tifffile
10 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [bdist_wheel]
2 | universal=1
3 |
4 | [aliases]
5 | test=pytest
6 |
7 | [yapf]
8 | based_on_style = pep8
9 | blank_line_before_nested_class_or_def = true
10 | split_before_expression_after_opening_paren = true
11 |
12 | [isort]
13 | line_length = 79
14 | multi_line_output = 0
15 | extra_standard_library = pkg_resources,setuptools,logging,os,warnings,abc
16 | known_first_party = mmcv
17 | known_third_party = addict,cv2,matplotlib,numpy,onnx,packaging,pytest,pytorch_sphinx_theme,scipy,sphinx,torch,torchvision,yaml,yapf
18 | no_lines_before = STDLIB,LOCALFOLDER
19 | default_section = THIRDPARTY
20 |
21 | # ignore-words-list needs to be lowercase format. For example, if we want to
22 | # ignore word "BA", then we need to append "ba" to ignore-words-list rather
23 | # than "BA"
24 | [codespell]
25 | quiet-level = 3
26 | ignore-words-list = inout,hist,ba,ro,inh
27 |
--------------------------------------------------------------------------------
/tests/data/batched_nms_data.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/batched_nms_data.pkl
--------------------------------------------------------------------------------
/tests/data/color.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/color.jpg
--------------------------------------------------------------------------------
/tests/data/color_exif.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/color_exif.jpg
--------------------------------------------------------------------------------
/tests/data/config/a.b.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item1 = [1, 2]
3 | item2 = {'a': 0}
4 | item3 = True
5 | item4 = 'test'
6 |
--------------------------------------------------------------------------------
/tests/data/config/a.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item1 = [1, 2]
3 | item2 = {'a': 0}
4 | item3 = True
5 | item4 = 'test'
6 |
--------------------------------------------------------------------------------
/tests/data/config/b.json:
--------------------------------------------------------------------------------
1 | {
2 | "item1": [1, 2],
3 | "item2": {
4 | "a": 0
5 | },
6 | "item3": true,
7 | "item4": "test"
8 | }
--------------------------------------------------------------------------------
/tests/data/config/base.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item1 = [1, 2]
3 | item2 = {'a': 0}
4 | item3 = True
5 | item4 = 'test'
6 |
--------------------------------------------------------------------------------
/tests/data/config/c.yaml:
--------------------------------------------------------------------------------
1 | item1: [1, 2]
2 | item2: {'a': 0}
3 | item3: True
4 | item4: 'test'
5 |
--------------------------------------------------------------------------------
/tests/data/config/code.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | from mmcv import Config # isort:skip
3 |
4 | cfg = Config.fromfile('./tests/data/config/a.py')
5 | item5 = cfg.item1[0] + cfg.item2.a
6 |
--------------------------------------------------------------------------------
/tests/data/config/d.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = './base.py'
3 | item1 = [2, 3]
4 | item2 = {'a': 1}
5 | item3 = False
6 | item4 = 'test_base'
7 |
--------------------------------------------------------------------------------
/tests/data/config/delete.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = './base.py'
3 | item1 = {'a': 0, '_delete_': True}
4 | item2 = {'b': 0}
5 |
--------------------------------------------------------------------------------
/tests/data/config/deprecated.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = './expected.py'
3 |
4 | _deprecation_ = dict(
5 | expected='tests/data/config/expected.py',
6 | reference='https://github.com/open-mmlab/mmcv/pull/1275')
7 |
--------------------------------------------------------------------------------
/tests/data/config/deprecated_as_base.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = './deprecated.py'
--------------------------------------------------------------------------------
/tests/data/config/e.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = './base.py'
3 | item3 = {'a': 1}
4 |
--------------------------------------------------------------------------------
/tests/data/config/expected.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item1 = 'expected'
3 |
--------------------------------------------------------------------------------
/tests/data/config/f.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = './d.py'
3 | item4 = 'test_recursive_bases'
4 |
--------------------------------------------------------------------------------
/tests/data/config/g.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | filename = 'reserved.py'
3 |
--------------------------------------------------------------------------------
/tests/data/config/h.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item1 = '{{fileBasename}}'
3 | item2 = '{{ fileDirname}}'
4 | item3 = 'abc_{{ fileBasenameNoExtension }}'
5 |
--------------------------------------------------------------------------------
/tests/data/config/i_base.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item1 = [1, 2]
3 | item2 = {'a': 0}
4 | item3 = True
5 | item4 = 'test'
6 | item_cfg = {'b': 1}
7 | item5 = {'cfg': item_cfg}
8 | item6 = {'cfg': item_cfg}
9 |
--------------------------------------------------------------------------------
/tests/data/config/i_child.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = './i_base.py'
3 | item_cfg = {'b': 2}
4 | item6 = {'cfg': item_cfg}
5 |
--------------------------------------------------------------------------------
/tests/data/config/l.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import os.path as osp
3 |
4 |
5 | def func(x):
6 | return x
7 |
8 | _base_ = ['./l1.py', './l2.yaml', './l3.json', './l4.py']
9 | item3 = False
10 | item4 = 'test'
11 |
--------------------------------------------------------------------------------
/tests/data/config/l1.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item1 = [1, 2]
3 |
--------------------------------------------------------------------------------
/tests/data/config/l2.yaml:
--------------------------------------------------------------------------------
1 | item2: {'a': 0}
2 |
--------------------------------------------------------------------------------
/tests/data/config/l3.json:
--------------------------------------------------------------------------------
1 | {
2 | "item3": true
3 | }
4 |
--------------------------------------------------------------------------------
/tests/data/config/l4.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item5 = dict(a=0, b=1)
3 | item6 = [dict(a=0), dict(b=1)]
4 | item7 = dict(a=[0, 1, 2], b=dict(c=[3.1, 4.2, 5.3]))
5 |
--------------------------------------------------------------------------------
/tests/data/config/m.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = ['./l1.py', './l2.yaml', './l3.json', 'a.py']
3 | item3 = False
4 | item4 = 'test'
5 |
--------------------------------------------------------------------------------
/tests/data/config/n.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import os.path as osp
3 |
4 |
5 | def func(x):
6 | return x
7 |
8 | test_item1 = [1, 2]
9 | bool_item2 = True
10 | str_item3 = 'test'
11 | dict_item4 = dict(
12 | a={
13 | 'c/d': 'path/d',
14 | 'f': 's3//f',
15 | 6: '2333',
16 | '2333': 'number'
17 | },
18 | b={'8': 543},
19 | c={9: 678},
20 | d={'a': 0},
21 | f=dict(a='69'))
22 | dict_item5 = {'x/x': {'a.0': 233}}
23 | dict_list_item6 = {'x/x': [{'a.0': 1., 'b.0': 2.}, {'c/3': 3.}]}
24 |
--------------------------------------------------------------------------------
/tests/data/config/o.json:
--------------------------------------------------------------------------------
1 | {
2 | "item1": "{{ fileDirname }}"
3 | }
4 |
--------------------------------------------------------------------------------
/tests/data/config/p.yaml:
--------------------------------------------------------------------------------
1 | item1: '{{ fileDirname }}'
2 |
--------------------------------------------------------------------------------
/tests/data/config/q.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | custom_imports = dict(imports=['r'], allow_failed_imports=False)
3 |
--------------------------------------------------------------------------------
/tests/data/config/r.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import os
3 |
4 | os.environ["TEST_VALUE"] = 'test'
5 |
--------------------------------------------------------------------------------
/tests/data/config/s.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | item = [{'a': 0}, {'b': 0, 'c': 0}]
3 |
--------------------------------------------------------------------------------
/tests/data/config/t.json:
--------------------------------------------------------------------------------
1 | {
2 | "_base_": [
3 | "./l1.py",
4 | "./l2.yaml",
5 | "./l3.json",
6 | "./l4.py"
7 | ],
8 | "item3": false,
9 | "item4": "test",
10 | "item8": "{{fileBasename}}",
11 | "item9": {{ _base_.item2 }},
12 | "item10": {{ _base_.item7.b.c }}
13 | }
14 |
--------------------------------------------------------------------------------
/tests/data/config/t.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = ['./l1.py', './l2.yaml', './l3.json', './l4.py']
3 | item3 = False
4 | item4 = 'test'
5 | item8 = '{{fileBasename}}'
6 | item9 = {{ _base_.item2 }}
7 | item10 = {{ _base_.item7.b.c }}
8 |
--------------------------------------------------------------------------------
/tests/data/config/t.yaml:
--------------------------------------------------------------------------------
1 | _base_ : ['./l1.py', './l2.yaml', './l3.json', './l4.py']
2 | item3 : False
3 | item4 : 'test'
4 | item8 : '{{fileBasename}}'
5 | item9 : {{ _base_.item2 }}
6 | item10 : {{ _base_.item7.b.c }}
7 |
--------------------------------------------------------------------------------
/tests/data/config/u.json:
--------------------------------------------------------------------------------
1 | {
2 | "_base_": [
3 | "./t.py"
4 | ],
5 | "base": "_base_.item8",
6 | "item11": {{ _base_.item8 }},
7 | "item12": {{ _base_.item9 }},
8 | "item13": {{ _base_.item10 }},
9 | "item14": {{ _base_.item1 }},
10 | "item15": {
11 | "a": {
12 | "b": {{ _base_.item2 }}
13 | },
14 | "b": [
15 | {{ _base_.item3 }}
16 | ],
17 | "c": [{{ _base_.item4 }}],
18 | "d": [[
19 | {
20 | "e": {{ _base_.item5.a }}
21 | }
22 | ],
23 | {{ _base_.item6 }}],
24 | "e": {{ _base_.item1 }}
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/data/config/u.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = ['./t.py']
3 | base = '_base_.item8'
4 | item11 = {{ _base_.item8 }}
5 | item12 = {{ _base_.item9 }}
6 | item13 = {{ _base_.item10 }}
7 | item14 = {{ _base_.item1 }}
8 | item15 = dict(
9 | a = dict( b = {{ _base_.item2 }} ),
10 | b = [{{ _base_.item3 }}],
11 | c = [{{ _base_.item4 }}],
12 | d = [[dict(e = {{ _base_.item5.a }})],{{ _base_.item6 }}],
13 | e = {{ _base_.item1 }}
14 | )
15 |
--------------------------------------------------------------------------------
/tests/data/config/u.yaml:
--------------------------------------------------------------------------------
1 | _base_: ["./t.py"]
2 | base: "_base_.item8"
3 | item11: {{ _base_.item8 }}
4 | item12: {{ _base_.item9 }}
5 | item13: {{ _base_.item10 }}
6 | item14: {{ _base_.item1 }}
7 | item15:
8 | a:
9 | b: {{ _base_.item2 }}
10 | b: [{{ _base_.item3 }}]
11 | c: [{{ _base_.item4 }}]
12 | d:
13 | - [e: {{ _base_.item5.a }}]
14 | - {{ _base_.item6 }}
15 | e: {{ _base_.item1 }}
16 |
--------------------------------------------------------------------------------
/tests/data/config/v.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | _base_ = ['./u.py']
3 | item21 = {{ _base_.item11 }}
4 | item22 = item21
5 | item23 = {{ _base_.item10 }}
6 | item24 = item23
7 | item25 = dict(
8 | a = dict( b = item24 ),
9 | b = [item24],
10 | c = [[dict(e = item22)],{{ _base_.item6 }}],
11 | e = item21
12 | )
13 |
--------------------------------------------------------------------------------
/tests/data/demo.lmdb/data.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/demo.lmdb/data.mdb
--------------------------------------------------------------------------------
/tests/data/demo.lmdb/lock.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/demo.lmdb/lock.mdb
--------------------------------------------------------------------------------
/tests/data/filelist.txt:
--------------------------------------------------------------------------------
1 | 1.jpg
2 | 2.jpg
3 | 3.jpg
4 | 4.jpg
5 | 5.jpg
--------------------------------------------------------------------------------
/tests/data/for_3d_ops/features_for_fps_distance.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_3d_ops/features_for_fps_distance.npy
--------------------------------------------------------------------------------
/tests/data/for_3d_ops/fps_idx.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_3d_ops/fps_idx.npy
--------------------------------------------------------------------------------
/tests/data/for_3d_ops/test_voxel.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_3d_ops/test_voxel.npy
--------------------------------------------------------------------------------
/tests/data/for_carafe/carafe_feat.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_carafe/carafe_feat.bin
--------------------------------------------------------------------------------
/tests/data/for_carafe/carafe_feat_grad.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_carafe/carafe_feat_grad.bin
--------------------------------------------------------------------------------
/tests/data/for_carafe/carafe_mask.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_carafe/carafe_mask.bin
--------------------------------------------------------------------------------
/tests/data/for_carafe/carafe_mask_grad.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_carafe/carafe_mask_grad.bin
--------------------------------------------------------------------------------
/tests/data/for_carafe/carafe_output.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_carafe/carafe_output.bin
--------------------------------------------------------------------------------
/tests/data/for_ccattention/ccattention_input.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_ccattention/ccattention_input.bin
--------------------------------------------------------------------------------
/tests/data/for_ccattention/ccattention_output.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_ccattention/ccattention_output.bin
--------------------------------------------------------------------------------
/tests/data/for_masked_conv2d/masked_conv2d_for_bias.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_masked_conv2d/masked_conv2d_for_bias.npy
--------------------------------------------------------------------------------
/tests/data/for_masked_conv2d/masked_conv2d_for_input.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_masked_conv2d/masked_conv2d_for_input.npy
--------------------------------------------------------------------------------
/tests/data/for_masked_conv2d/masked_conv2d_for_mask.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_masked_conv2d/masked_conv2d_for_mask.npy
--------------------------------------------------------------------------------
/tests/data/for_masked_conv2d/masked_conv2d_for_output.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_masked_conv2d/masked_conv2d_for_output.npy
--------------------------------------------------------------------------------
/tests/data/for_masked_conv2d/masked_conv2d_for_weight.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_masked_conv2d/masked_conv2d_for_weight.npy
--------------------------------------------------------------------------------
/tests/data/for_psa_mask/psa_input.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_psa_mask/psa_input.bin
--------------------------------------------------------------------------------
/tests/data/for_psa_mask/psa_output_collect.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_psa_mask/psa_output_collect.bin
--------------------------------------------------------------------------------
/tests/data/for_psa_mask/psa_output_distribute.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_psa_mask/psa_output_distribute.bin
--------------------------------------------------------------------------------
/tests/data/for_scan/.file:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/.file
--------------------------------------------------------------------------------
/tests/data/for_scan/1.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/1.json
--------------------------------------------------------------------------------
/tests/data/for_scan/1.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/1.txt
--------------------------------------------------------------------------------
/tests/data/for_scan/2.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/2.json
--------------------------------------------------------------------------------
/tests/data/for_scan/2.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/2.txt
--------------------------------------------------------------------------------
/tests/data/for_scan/3.TXT:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/3.TXT
--------------------------------------------------------------------------------
/tests/data/for_scan/a.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/a.bin
--------------------------------------------------------------------------------
/tests/data/for_scan/sub/1.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/sub/1.json
--------------------------------------------------------------------------------
/tests/data/for_scan/sub/1.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/for_scan/sub/1.txt
--------------------------------------------------------------------------------
/tests/data/gray_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/gray_alpha.png
--------------------------------------------------------------------------------
/tests/data/grayscale.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/grayscale.jpg
--------------------------------------------------------------------------------
/tests/data/grayscale_dim3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/grayscale_dim3.jpg
--------------------------------------------------------------------------------
/tests/data/mapping.txt:
--------------------------------------------------------------------------------
1 | 1 cat
2 | 2 dog cow
3 | 3 panda
--------------------------------------------------------------------------------
/tests/data/optflow.flo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/optflow.flo
--------------------------------------------------------------------------------
/tests/data/optflow_concat0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/optflow_concat0.jpg
--------------------------------------------------------------------------------
/tests/data/optflow_concat1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/optflow_concat1.jpg
--------------------------------------------------------------------------------
/tests/data/palette.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/palette.gif
--------------------------------------------------------------------------------
/tests/data/patches/0.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/0.npy
--------------------------------------------------------------------------------
/tests/data/patches/1.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/1.npy
--------------------------------------------------------------------------------
/tests/data/patches/2.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/2.npy
--------------------------------------------------------------------------------
/tests/data/patches/3.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/3.npy
--------------------------------------------------------------------------------
/tests/data/patches/4.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/4.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad0_0.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad0_0.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad0_1.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad0_1.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad0_2.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad0_2.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad0_3.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad0_3.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad0_4.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad0_4.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad_0.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad_0.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad_1.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad_1.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad_2.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad_2.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad_3.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad_3.npy
--------------------------------------------------------------------------------
/tests/data/patches/pad_4.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/pad_4.npy
--------------------------------------------------------------------------------
/tests/data/patches/scale_0.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/scale_0.npy
--------------------------------------------------------------------------------
/tests/data/patches/scale_1.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/scale_1.npy
--------------------------------------------------------------------------------
/tests/data/patches/scale_2.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/scale_2.npy
--------------------------------------------------------------------------------
/tests/data/patches/scale_3.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/scale_3.npy
--------------------------------------------------------------------------------
/tests/data/patches/scale_4.npy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/patches/scale_4.npy
--------------------------------------------------------------------------------
/tests/data/scripts/hello.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | #!/usr/bin/env python
3 |
4 | import argparse
5 | import warnings
6 |
7 |
8 | def parse_args():
9 | parser = argparse.ArgumentParser(description='Say hello.')
10 | parser.add_argument('name', help='To whom.')
11 |
12 | args = parser.parse_args()
13 |
14 | return args
15 |
16 |
17 | def main():
18 | args = parse_args()
19 | print(f'hello {args.name}!')
20 | if args.name == 'agent':
21 | warnings.warn('I have a secret!')
22 |
23 |
24 | if __name__ == '__main__':
25 | main()
26 |
--------------------------------------------------------------------------------
/tests/data/sparse_flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/sparse_flow.png
--------------------------------------------------------------------------------
/tests/data/test.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/test.mp4
--------------------------------------------------------------------------------
/tests/data/uint16-5channel.tif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/data/uint16-5channel.tif
--------------------------------------------------------------------------------
/tests/test_cnn/test_conv2d_adaptive_padding.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 |
4 | from mmcv.cnn.bricks import Conv2dAdaptivePadding
5 |
6 |
7 | def test_conv2d_samepadding():
8 | # test Conv2dAdaptivePadding with stride=1
9 | inputs = torch.rand((1, 3, 28, 28))
10 | conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=1)
11 | output = conv(inputs)
12 | assert output.shape == inputs.shape
13 |
14 | inputs = torch.rand((1, 3, 13, 13))
15 | conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=1)
16 | output = conv(inputs)
17 | assert output.shape == inputs.shape
18 |
19 | # test Conv2dAdaptivePadding with stride=2
20 | inputs = torch.rand((1, 3, 28, 28))
21 | conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=2)
22 | output = conv(inputs)
23 | assert output.shape == torch.Size([1, 3, 14, 14])
24 |
25 | inputs = torch.rand((1, 3, 13, 13))
26 | conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=2)
27 | output = conv(inputs)
28 | assert output.shape == torch.Size([1, 3, 7, 7])
29 |
--------------------------------------------------------------------------------
/tests/test_cnn/test_fuse_conv_bn.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 | import torch.nn as nn
4 |
5 | from mmcv.cnn import ConvModule, fuse_conv_bn
6 |
7 |
8 | def test_fuse_conv_bn():
9 | inputs = torch.rand((1, 3, 5, 5))
10 | modules = nn.ModuleList()
11 | modules.append(nn.BatchNorm2d(3))
12 | modules.append(ConvModule(3, 5, 3, norm_cfg=dict(type='BN')))
13 | modules.append(ConvModule(5, 5, 3, norm_cfg=dict(type='BN')))
14 | modules = nn.Sequential(*modules)
15 | fused_modules = fuse_conv_bn(modules)
16 | assert torch.equal(modules(inputs), fused_modules(inputs))
17 |
--------------------------------------------------------------------------------
/tests/test_cnn/test_hsigmoid.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import pytest
3 | import torch
4 |
5 | from mmcv.cnn.bricks import HSigmoid
6 |
7 |
8 | def test_hsigmoid():
9 | # test assertion divisor can not be zero
10 | with pytest.raises(AssertionError):
11 | HSigmoid(divisor=0)
12 |
13 | # test with default parameters
14 | act = HSigmoid()
15 | input_shape = torch.Size([1, 3, 64, 64])
16 | input = torch.randn(input_shape)
17 | output = act(input)
18 | expected_output = torch.min(
19 | torch.max((input + 3) / 6, torch.zeros(input_shape)),
20 | torch.ones(input_shape))
21 | # test output shape
22 | assert output.shape == expected_output.shape
23 | # test output value
24 | assert torch.equal(output, expected_output)
25 |
26 | # test with designated parameters
27 | act = HSigmoid(1, 2, 0, 1)
28 | input_shape = torch.Size([1, 3, 64, 64])
29 | input = torch.randn(input_shape)
30 | output = act(input)
31 | expected_output = torch.min(
32 | torch.max((input + 1) / 2, torch.zeros(input_shape)),
33 | torch.ones(input_shape))
34 | # test output shape
35 | assert output.shape == expected_output.shape
36 | # test output value
37 | assert torch.equal(output, expected_output)
38 |
--------------------------------------------------------------------------------
/tests/test_cnn/test_hswish.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 | from torch.nn.functional import relu6
4 |
5 | from mmcv.cnn.bricks import HSwish
6 |
7 |
8 | def test_hswish():
9 | # test inplace
10 | act = HSwish(inplace=True)
11 | assert act.act.inplace
12 | act = HSwish()
13 | assert not act.act.inplace
14 |
15 | input = torch.randn(1, 3, 64, 64)
16 | expected_output = input * relu6(input + 3) / 6
17 | output = act(input)
18 | # test output shape
19 | assert output.shape == expected_output.shape
20 | # test output value
21 | assert torch.equal(output, expected_output)
22 |
--------------------------------------------------------------------------------
/tests/test_cnn/test_silu.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 |
4 | from mmcv.cnn.bricks import build_activation_layer
5 |
6 |
7 | def test_silu():
8 | act = build_activation_layer(dict(type='SiLU'))
9 | input = torch.randn(1, 3, 64, 64)
10 | expected_output = input * torch.sigmoid(input)
11 | output = act(input)
12 | # test output shape
13 | assert output.shape == expected_output.shape
14 | # test output value
15 | assert torch.allclose(output, expected_output)
16 |
17 | # test inplace
18 | act = build_activation_layer(dict(type='SiLU', inplace=True))
19 | assert act.inplace
20 | input = torch.randn(1, 3, 64, 64)
21 | expected_output = input * torch.sigmoid(input)
22 | output = act(input)
23 | # test output shape
24 | assert output.shape == expected_output.shape
25 | # test output value
26 | assert torch.allclose(output, expected_output)
27 | assert torch.allclose(input, expected_output)
28 | assert input is output
29 |
--------------------------------------------------------------------------------
/tests/test_cnn/test_swish.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 | import torch.nn.functional as F
4 |
5 | from mmcv.cnn.bricks import Swish
6 |
7 |
8 | def test_swish():
9 | act = Swish()
10 | input = torch.randn(1, 3, 64, 64)
11 | expected_output = input * F.sigmoid(input)
12 | output = act(input)
13 | # test output shape
14 | assert output.shape == expected_output.shape
15 | # test output value
16 | assert torch.equal(output, expected_output)
17 |
--------------------------------------------------------------------------------
/tests/test_ops/output.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/open-mmlab/mmcv/90d83c94cfb967ef162c449faf559616f31f28c2/tests/test_ops/output.pkl
--------------------------------------------------------------------------------
/tests/test_ops/test_info.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import torch
3 |
4 |
5 | class TestInfo:
6 |
7 | def test_info(self):
8 | if not torch.cuda.is_available():
9 | return
10 | from mmcv.ops import get_compiler_version, get_compiling_cuda_version
11 | cv = get_compiler_version()
12 | ccv = get_compiling_cuda_version()
13 | assert cv is not None
14 | assert ccv is not None
15 |
--------------------------------------------------------------------------------
/tests/test_ops/test_min_area_polygons.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import numpy as np
3 | import pytest
4 | import torch
5 |
6 | from mmcv.ops import min_area_polygons
7 | from mmcv.utils import IS_CUDA_AVAILABLE, IS_MUSA_AVAILABLE
8 |
9 | np_pointsets = np.asarray([[
10 | 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0, 1.0, 1.0, 3.0, 3.0, 1.0, 2.0, 3.0, 3.0,
11 | 2.0, 1.5, 1.5
12 | ],
13 | [
14 | 1.0, 1.0, 8.0, 8.0, 1.0, 2.0, 2.0, 1.0, 1.0,
15 | 3.0, 3.0, 1.0, 2.0, 3.0, 3.0, 2.0, 1.5, 1.5
16 | ]])
17 |
18 | expected_polygons = np.asarray(
19 | [[3.0000, 1.0000, 1.0000, 1.0000, 1.0000, 3.0000, 3.0000, 3.0000],
20 | [8.0, 8.0, 2.3243, 0.0541, 0.0541, 1.6757, 5.7297, 9.6216]])
21 |
22 |
23 | @pytest.mark.parametrize('device', [
24 | pytest.param(
25 | 'cuda',
26 | marks=pytest.mark.skipif(
27 | not IS_CUDA_AVAILABLE, reason='requires CUDA support')),
28 | pytest.param(
29 | 'musa',
30 | marks=pytest.mark.skipif(
31 | not IS_MUSA_AVAILABLE, reason='requires MUSA support'))
32 | ])
33 | def test_min_area_polygons(device):
34 | pointsets = torch.from_numpy(np_pointsets).to(device).float()
35 |
36 | assert np.allclose(
37 | min_area_polygons(pointsets).cpu().numpy(),
38 | expected_polygons,
39 | atol=1e-4)
40 |
--------------------------------------------------------------------------------
/tests/test_utils/test_env.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import sys
3 |
4 | import pytest
5 |
6 | import mmcv
7 |
8 |
9 | def test_collect_env():
10 | try:
11 | import torch # noqa: F401
12 | except ModuleNotFoundError:
13 | pytest.skip('skipping tests that require PyTorch')
14 |
15 | from mmcv.utils import collect_env
16 | env_info = collect_env()
17 | expected_keys = [
18 | 'sys.platform', 'Python', 'CUDA available', 'PyTorch',
19 | 'PyTorch compiling details', 'OpenCV', 'MMCV', 'MMCV Compiler', 'GCC',
20 | 'MMCV CUDA Compiler'
21 | ]
22 | for key in expected_keys:
23 | assert key in env_info
24 |
25 | if env_info['CUDA available']:
26 | for key in ['CUDA_HOME', 'NVCC']:
27 | assert key in env_info
28 |
29 | if sys.platform == 'win32':
30 | assert 'MSVC' in env_info
31 |
32 | assert env_info['sys.platform'] == sys.platform
33 | assert env_info['Python'] == sys.version.replace('\n', '')
34 | assert env_info['MMCV'] == mmcv.__version__
35 |
--------------------------------------------------------------------------------
/tests/test_visualization.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) OpenMMLab. All rights reserved.
2 | import numpy as np
3 | import pytest
4 |
5 | import mmcv
6 |
7 |
8 | def test_color():
9 | assert mmcv.color_val(mmcv.Color.blue) == (255, 0, 0)
10 | assert mmcv.color_val('green') == (0, 255, 0)
11 | assert mmcv.color_val((1, 2, 3)) == (1, 2, 3)
12 | assert mmcv.color_val(100) == (100, 100, 100)
13 | assert mmcv.color_val(np.zeros(3, dtype=int)) == (0, 0, 0)
14 | with pytest.raises(TypeError):
15 | mmcv.color_val([255, 255, 255])
16 | with pytest.raises(TypeError):
17 | mmcv.color_val(1.0)
18 | with pytest.raises(AssertionError):
19 | mmcv.color_val((0, 0, 500))
20 |
--------------------------------------------------------------------------------