Skip to content

Commit 2b6d24a

Browse files
committed
remove unused rewritings for mask2former
1 parent 3a58869 commit 2b6d24a

File tree

7 files changed

+11
-293
lines changed

7 files changed

+11
-293
lines changed

configs/mmdet/panoptic-seg/panoptic-seg_maskformer_onnxruntime_dynamic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
},
1414
'cls_logits': {
1515
0: 'batch',
16-
2: 'h',
17-
3: 'w',
16+
1: 'query',
1817
},
1918
'mask_logits': {
2019
0: 'batch',
20+
1: 'query',
2121
2: 'h',
2222
3: 'w',
2323
},

configs/mmdet/panoptic-seg/panoptic-seg_maskformer_tensorrt_dynamic-320x512-1344x1344.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
},
1414
'cls_logits': {
1515
0: 'batch',
16-
2: 'h',
17-
3: 'w',
16+
1: 'query',
1817
},
1918
'mask_logits': {
2019
0: 'batch',
20+
1: 'query',
2121
2: 'h',
2222
3: 'w',
2323
},

mmdeploy/codebase/mmdet/models/dense_heads/mask2former_head.py

Lines changed: 0 additions & 94 deletions
This file was deleted.

mmdeploy/codebase/mmdet/models/layers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
# recovery for mmyolo
33
from mmdeploy.mmcv.ops import multiclass_nms # noqa: F401, F403
44
from . import matrix_nms # noqa: F401, F403
5-
from . import msdeformattn_pixel_decoder # noqa: F401, F403
65

76
__all__ = ['multiclass_nms']

mmdeploy/codebase/mmdet/models/layers/msdeformattn_pixel_decoder.py

Lines changed: 0 additions & 125 deletions
This file was deleted.
Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
2-
import torch
3-
import torch.nn.functional as F
42

5-
from mmdeploy.core import FUNCTION_REWRITER, SYMBOLIC_REWRITER
3+
from mmdeploy.core import SYMBOLIC_REWRITER
64

75

86
@SYMBOLIC_REWRITER.register_symbolic(
@@ -26,63 +24,3 @@ def ms_deform_attn_default(
2624
attention_weights,
2725
im2col_step_i=im2col_step,
2826
)
29-
30-
31-
@FUNCTION_REWRITER.register_rewriter(
32-
'mmcv.ops.multi_scale_deform_attn.multi_scale_deformable_attn_pytorch')
33-
def multi_scale_deformable_attn_pytorch_default(
34-
value: torch.Tensor, value_spatial_shapes: torch.Tensor,
35-
sampling_locations: torch.Tensor,
36-
attention_weights: torch.Tensor) -> torch.Tensor:
37-
"""CPU version of multi-scale deformable attention.
38-
39-
Args:
40-
value (torch.Tensor): The value has shape
41-
(bs, num_keys, num_heads, embed_dims//num_heads)
42-
value_spatial_shapes (torch.Tensor): Spatial shape of
43-
each feature map, has shape (num_levels, 2),
44-
last dimension 2 represent (h, w)
45-
sampling_locations (torch.Tensor): The location of sampling points,
46-
has shape
47-
(bs ,num_queries, num_heads, num_levels, num_points, 2),
48-
the last dimension 2 represent (x, y).
49-
attention_weights (torch.Tensor): The weight of sampling points used
50-
when calculate the attention, has shape
51-
(bs ,num_queries, num_heads, num_levels, num_points),
52-
53-
Returns:
54-
torch.Tensor: has shape (bs, num_queries, embed_dims)
55-
"""
56-
57-
bs, _, num_heads, embed_dims = value.shape
58-
_, num_queries, num_heads, num_levels, num_points, _ =\
59-
sampling_locations.shape
60-
indices = torch.cat((value_spatial_shapes.new_zeros(1),
61-
value_spatial_shapes.prod(1).cumsum(0)))
62-
# avoid split with dynamic split_sizes
63-
# value_list = value.split([H_ * W_ for H_, W_ in value_spatial_shapes],
64-
# dim=1)
65-
sampling_grids = 2 * sampling_locations - 1
66-
sampling_value_list = []
67-
for i in range(num_levels):
68-
H_, W_ = value_spatial_shapes[i]
69-
value_l_ = value[:, indices[i]:indices[i + 1], :, :]
70-
value_l_ = value_l_.flatten(2).transpose(1, 2).reshape(
71-
bs * num_heads, embed_dims, H_, W_)
72-
sampling_grid_l_ = sampling_grids[:, :, :,
73-
i].transpose(1, 2).flatten(0, 1)
74-
# bs*num_heads, embed_dims, num_queries, num_points
75-
sampling_value_l_ = F.grid_sample(
76-
value_l_,
77-
sampling_grid_l_,
78-
mode='bilinear',
79-
padding_mode='zeros',
80-
align_corners=False)
81-
sampling_value_list.append(sampling_value_l_)
82-
83-
attention_weights = attention_weights.transpose(1, 2).reshape(
84-
bs * num_heads, 1, num_queries, num_levels * num_points)
85-
output = (torch.stack(sampling_value_list, dim=-2).flatten(-2) *
86-
attention_weights).sum(-1).view(bs, num_heads * embed_dims,
87-
num_queries)
88-
return output.transpose(1, 2).contiguous()

tests/regression/mmdet.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,21 +399,21 @@ models:
399399
model_configs:
400400
- configs/maskformer/maskformer_r50_ms-16xb1-75e_coco.py
401401
pipelines:
402-
- deploy_config: configs/mmdet/panoptic-seg/panoptic-seg_maskformer_onnxruntime_static-800x1344.py
402+
- deploy_config: configs/mmdet/panoptic-seg/panoptic-seg_maskformer_onnxruntime_dynamic.py
403403
convert_image: *convert_image
404404
backend_test: False
405-
- deploy_config: configs/mmdet/panoptic-seg/panoptic-seg_maskformer_tensorrt_static-800x1344.py
405+
- deploy_config: configs/mmdet/panoptic-seg/panoptic-seg_maskformer_tensorrt_dynamic-320x512-1344x1344.py
406406
convert_image: *convert_image
407-
backend_test: False
407+
backend_test: True
408408

409409
- name: Mask2Former
410410
metafile: configs/mask2former/metafile.yml
411411
model_configs:
412412
- configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco-panoptic.py
413413
pipelines:
414-
- deploy_config: configs/mmdet/panoptic-seg/panoptic-seg_maskformer_onnxruntime_static-800x1344.py
414+
- deploy_config: configs/mmdet/panoptic-seg/panoptic-seg_maskformer_onnxruntime_dynamic.py
415415
convert_image: *convert_image
416416
backend_test: False
417-
- deploy_config: configs/mmdet/panoptic-seg/panoptic-seg_maskformer_tensorrt_static-800x1344.py
417+
- deploy_config: configs/mmdet/panoptic-seg/panoptic-seg_maskformer_tensorrt_dynamic-320x512-1344x1344.py
418418
convert_image: *convert_image
419-
backend_test: False
419+
backend_test: True

0 commit comments

Comments
 (0)