Skip to content

Commit

Permalink
fix (dpool): directly return empty if rois's length is 0 (#2099)
Browse files Browse the repository at this point in the history
* fix (dpool): directly return empty if rois's length is 0

* fix (dpool): also skip empty when no_trans=True

* reformat (test/test_dpool.py): reformat to pass flake8

* fix (test_dpool): skip gpu test when GPU is not avaliable

* rm (test_dpool.py): rm test_dpool since it is not very necessary in CI
  • Loading branch information
ZwwWayne committed Feb 17, 2020
1 parent 923b70a commit c0ac99e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mmdet/ops/dcn/deform_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def __init__(self,

def forward(self, data, rois):
assert data.size(1) == self.out_channels
n = rois.shape[0]
if n == 0:
return data.new_empty(n, self.out_channels, self.out_size[0],
self.out_size[1])
if self.no_trans:
offset = data.new_empty(0)
return deform_roi_pooling(data, rois, offset, self.spatial_scale,
Expand All @@ -156,7 +160,6 @@ def forward(self, data, rois):
self.part_size, self.sample_per_part,
self.trans_std)
else:
n = rois.shape[0]
offset = data.new_empty(0)
x = deform_roi_pooling(data, rois, offset, self.spatial_scale,
self.out_size, self.out_channels, True,
Expand Down Expand Up @@ -228,6 +231,10 @@ def __init__(self,

def forward(self, data, rois):
assert data.size(1) == self.out_channels
n = rois.shape[0]
if n == 0:
return data.new_empty(n, self.out_channels, self.out_size[0],
self.out_size[1])
if self.no_trans:
offset = data.new_empty(0)
return deform_roi_pooling(data, rois, offset, self.spatial_scale,
Expand All @@ -236,7 +243,6 @@ def forward(self, data, rois):
self.part_size, self.sample_per_part,
self.trans_std)
else:
n = rois.shape[0]
offset = data.new_empty(0)
x = deform_roi_pooling(data, rois, offset, self.spatial_scale,
self.out_size, self.out_channels, True,
Expand Down

0 comments on commit c0ac99e

Please sign in to comment.