Skip to content

Commit

Permalink
Remove the inplace addition in FPN (#7175)
Browse files Browse the repository at this point in the history
* [Fix] Fix wrong img name in onnx2tensorrt.py (#7157)

* [Docs] fix albumentations installed way (#7143)

* Remove the inplace addition in `FPN`

* update

Co-authored-by: Jamie <[email protected]>
Co-authored-by: BigDong <[email protected]>
Co-authored-by: PJLAB\huanghaian <[email protected]>
  • Loading branch information
4 people authored Feb 22, 2022
1 parent 613daca commit 220c0da
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mmdet/models/necks/fpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,12 @@ def forward(self, inputs):
# In some cases, fixing `scale factor` (e.g. 2) is preferred, but
# it cannot co-exist with `size` in `F.interpolate`.
if 'scale_factor' in self.upsample_cfg:
laterals[i - 1] += F.interpolate(laterals[i],
**self.upsample_cfg)
# fix runtime error of "+=" inplace operation in PyTorch 1.10
laterals[i - 1] = laterals[i - 1] + F.interpolate(
laterals[i], **self.upsample_cfg)
else:
prev_shape = laterals[i - 1].shape[2:]
laterals[i - 1] += F.interpolate(
laterals[i - 1] = laterals[i - 1] + F.interpolate(
laterals[i], size=prev_shape, **self.upsample_cfg)

# build outputs
Expand Down

0 comments on commit 220c0da

Please sign in to comment.