File size: 8,730 Bytes
6ed4a9c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | ### v2.0.0
The OpenMMLab team released a new generation of training engine [MMEngine](https://github.com/open-mmlab/mmengine) at the World Artificial Intelligence Conference on September 1, 2022. It is a foundational library for training deep learning models. Compared with MMCV, it provides a universal and powerful runner, an open architecture with a more unified interface, and a more customizable training process.
The OpenMMLab team released MMCV v2.0.0 on April 6, 2023. In the 2.x version, it has the following significant changes:
(1) It removed the following components:
- `mmcv.fileio` module, removed in PR [#2179](https://github.com/open-mmlab/mmcv/pull/2179). FileIO module from mmengine will be used wherever required.
- `mmcv.runner`, `mmcv.parallel`, `mmcv. engine` and `mmcv.device`, removed in PR [#2216](https://github.com/open-mmlab/mmcv/pull/2216).
- All classes in `mmcv.utils` (eg `Config` and `Registry`) and many functions, removed in PR [#2217](https://github.com/open-mmlab/mmcv/pull/2217). Only a few functions related to mmcv are reserved.
- `mmcv.onnx`, `mmcv.tensorrt` modules and related functions, removed in PR [#2225](https://github.com/open-mmlab/mmcv/pull/2225).
- Removed all root registrars in MMCV and registered classes or functions to the [root registrar](https://github.com/open-mmlab/mmengine/blob/main/mmengine/registry/root.py) in MMEngine.
(2) It added the [`mmcv.transforms`](https://github.com/open-mmlab/mmcv/tree/main/mmcv/transforms) data transformation module.
(3) It renamed the package name **mmcv** to **mmcv-lite** and **mmcv-full** to **mmcv** in PR [#2235](https://github.com/open-mmlab/mmcv/pull/2235). Also, change the default value of the environment variable `MMCV_WITH_OPS` from 0 to 1.
<table class="docutils">
<thead>
<tr>
<th align="center">MMCV < 2.0</th>
<th align="center">MMCV >= 2.0 </th>
<tbody>
<tr>
<td valign="top">
```bash
# Contains ops, because the highest version of mmcv-full is less than 2.0.0, so there is no need to add version restrictions
pip install openmim
mim install mmcv-full
# do not contain ops
pip install openmim
mim install "mmcv < 2.0.0"
```
</td>
<td valign="top">
```bash
# Contains ops
pip install openmim
mim install mmcv
# Ops are not included, because the starting version of mmcv-lite is 2.0.0rc1, so there is no need to add version restrictions
pip install openmim
mim install mmcv-lite
```
</td>
</tr>
</thead>
</table>
### v1.3.18
Some ops have different implementations on different devices. Lots of macros and type checks are scattered in several files, which makes the code hard to maintain. For example:
```c++
if (input.device().is_cuda()) {
#ifdef MMCV_WITH_CUDA
CHECK_CUDA_INPUT(input);
CHECK_CUDA_INPUT(rois);
CHECK_CUDA_INPUT(output);
CHECK_CUDA_INPUT(argmax_y);
CHECK_CUDA_INPUT(argmax_x);
roi_align_forward_cuda(input, rois, output, argmax_y, argmax_x,
aligned_height, aligned_width, spatial_scale,
sampling_ratio, pool_mode, aligned);
#else
AT_ERROR("RoIAlign is not compiled with GPU support");
#endif
} else {
CHECK_CPU_INPUT(input);
CHECK_CPU_INPUT(rois);
CHECK_CPU_INPUT(output);
CHECK_CPU_INPUT(argmax_y);
CHECK_CPU_INPUT(argmax_x);
roi_align_forward_cpu(input, rois, output, argmax_y, argmax_x,
aligned_height, aligned_width, spatial_scale,
sampling_ratio, pool_mode, aligned);
}
```
Registry and dispatcher are added to manage these implementations.
```c++
void ROIAlignForwardCUDAKernelLauncher(Tensor input, Tensor rois, Tensor output,
Tensor argmax_y, Tensor argmax_x,
int aligned_height, int aligned_width,
float spatial_scale, int sampling_ratio,
int pool_mode, bool aligned);
void roi_align_forward_cuda(Tensor input, Tensor rois, Tensor output,
Tensor argmax_y, Tensor argmax_x,
int aligned_height, int aligned_width,
float spatial_scale, int sampling_ratio,
int pool_mode, bool aligned) {
ROIAlignForwardCUDAKernelLauncher(
input, rois, output, argmax_y, argmax_x, aligned_height, aligned_width,
spatial_scale, sampling_ratio, pool_mode, aligned);
}
// register cuda implementation
void roi_align_forward_impl(Tensor input, Tensor rois, Tensor output,
Tensor argmax_y, Tensor argmax_x,
int aligned_height, int aligned_width,
float spatial_scale, int sampling_ratio,
int pool_mode, bool aligned);
REGISTER_DEVICE_IMPL(roi_align_forward_impl, CUDA, roi_align_forward_cuda);
// roi_align.cpp
// use the dispatcher to invoke different implementation depending on device type of input tensors.
void roi_align_forward_impl(Tensor input, Tensor rois, Tensor output,
Tensor argmax_y, Tensor argmax_x,
int aligned_height, int aligned_width,
float spatial_scale, int sampling_ratio,
int pool_mode, bool aligned) {
DISPATCH_DEVICE_IMPL(roi_align_forward_impl, input, rois, output, argmax_y,
argmax_x, aligned_height, aligned_width, spatial_scale,
sampling_ratio, pool_mode, aligned);
}
```
### v1.3.11
In order to flexibly support more backends and hardwares like `NVIDIA GPUs` and `AMD GPUs`, the directory of `mmcv/ops/csrc` is refactored. Note that this refactoring will not affect the usage in API. For related information, please refer to [PR1206](https://github.com/open-mmlab/mmcv/pull/1206).
The original directory was organized as follows.
```
.
βββ common_cuda_helper.hpp
βββ ops_cuda_kernel.cuh
βββ pytorch_cpp_helper.hpp
βββ pytorch_cuda_helper.hpp
βββ parrots_cpp_helper.hpp
βββ parrots_cuda_helper.hpp
βββ parrots_cudawarpfunction.cuh
βββ onnxruntime
βΒ Β βββ onnxruntime_register.h
βΒ Β βββ onnxruntime_session_options_config_keys.h
βΒ Β βββ ort_mmcv_utils.h
βΒ Β βββ ...
βΒ Β βββ onnx_ops.h
βΒ Β βββ cpu
β βββ onnxruntime_register.cpp
βΒ Β Β Β βββ ...
βΒ Β Β Β βββ onnx_ops_impl.cpp
βββ parrots
βΒ Β βββ ...
βΒ Β βββ ops.cpp
βΒ Β βββ ops_cuda.cu
βΒ Β βββ ops_parrots.cpp
βΒ Β βββ ops_pytorch.h
βββ pytorch
βΒ Β βββ ...
βΒ Β βββ ops.cpp
βΒ Β βββ ops_cuda.cu
βΒ Β βββ pybind.cpp
βββ tensorrt
βββ trt_cuda_helper.cuh
βββ trt_plugin_helper.hpp
βββ trt_plugin.hpp
βββ trt_serialize.hpp
βββ ...
βββ trt_ops.hpp
βββ plugins
Β Β βββ trt_cuda_helper.cu
Β Β βββ trt_plugin.cpp
Β Β βββ ...
Β Β βββ trt_ops.cpp
Β Β βββ trt_ops_kernel.cu
```
After refactored, it is organized as follows.
```
.
βββ common
β βββ box_iou_rotated_utils.hpp
β βββ parrots_cpp_helper.hpp
β βββ parrots_cuda_helper.hpp
β βββ pytorch_cpp_helper.hpp
β βββ pytorch_cuda_helper.hpp
βΒ Β βββ cuda
βΒ Β βββ common_cuda_helper.hpp
βΒ Β βββ parrots_cudawarpfunction.cuh
βΒ Β βββ ...
βΒ Β βββ ops_cuda_kernel.cuh
βββ onnxruntime
βΒ Β βββ onnxruntime_register.h
βΒ Β βββ onnxruntime_session_options_config_keys.h
βΒ Β βββ ort_mmcv_utils.h
βΒ Β βββ ...
βΒ Β βββ onnx_ops.h
βΒ Β βββ cpu
β βββ onnxruntime_register.cpp
βΒ Β Β Β βββ ...
βΒ Β Β Β βββ onnx_ops_impl.cpp
βββ parrots
βΒ Β βββ ...
βΒ Β βββ ops.cpp
βΒ Β βββ ops_parrots.cpp
βΒ Β βββ ops_pytorch.h
βββ pytorch
βΒ Β βββ info.cpp
βΒ Β βββ pybind.cpp
βΒ Β βββ ...
βΒ Β βββ ops.cpp
βΒ Β βββ cuda
βΒ Β Β Β βββ ...
βΒ Β Β Β βββ ops_cuda.cu
βββ tensorrt
βββ trt_cuda_helper.cuh
βββ trt_plugin_helper.hpp
βββ trt_plugin.hpp
βββ trt_serialize.hpp
βββ ...
βββ trt_ops.hpp
βββ plugins
Β Β βββ trt_cuda_helper.cu
Β Β βββ trt_plugin.cpp
Β Β βββ ...
Β Β βββ trt_ops.cpp
Β Β βββ trt_ops_kernel.cu
```
|