Skip to content

Commit

Permalink
Optimize PyTorch 1.11.0 compatibility update (#6933)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored Mar 10, 2022
1 parent d3d9cbc commit 055e72a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ def attempt_load(weights, map_location=None, inplace=True, fuse=True):
if not isinstance(m.anchor_grid, list): # new Detect Layer compatibility
delattr(m, 'anchor_grid')
setattr(m, 'anchor_grid', [torch.zeros(1)] * m.nl)
elif t is nn.Upsample:
m.recompute_scale_factor = None # torch 1.11.0 compatibility
elif t is Conv:
m._non_persistent_buffers_set = set() # torch 1.6.0 compatibility
elif t is nn.Upsample and not hasattr(m, 'recompute_scale_factor'):
m.recompute_scale_factor = None # torch 1.11.0 compatibility

if len(model) == 1:
return model[-1] # return model
Expand Down

0 comments on commit 055e72a

Please sign in to comment.